JavaBean - invalid method declaration and return type required
Hello, guys
i need some help. I wrote a java bean for database connection
Code:
import java.io.*;
import java.sql.*;
public class DBconnection {
String driverName = "org.gjt.mm.mysql.Driver";
String serverName = "localhost";
String database = "data";
String dbURL = "jdbc:mysql://" + serverName + "/" + database; // JDBC url
String username = "root";
String password = "root";
private Connection dbConnection;
Statement statement;
ResultSet resultSet;
public DBconnection() {
super();
}
public boolean connect() throws ClassNotFoundException, SQLException {
Class.forName(driverName);
dbConnection = DriverManager.getConnection(dbURL);
return true;
}
public void close() throws SQLException {
dbConnection.close();
}
public execSQL(String sql) throws SQLException {
statement = dbConnection.createStatement();
resultSet = statement.executeQuery(sql);
return (resultSet == null) ? null : resultSet;
}
}
and i get the following error:
DBconnection.java:31: invalid method declaration; return type required
public execSQL(String sql) throws SQLException {