i got the error above and below is my code what am i doin wrong? the error reference to the datasource. what is the problem?
public class DBConnector {
private Connection dbConn = null;
private FileLogger fileLogger = new FileLogger("./logs/logfile.txt");
private ConfigurationReader conf = new ConfigurationReader("./config.sys");
private Logger logger = fileLogger.getLogger();
/**
* Attempts to establish a connection with a test MySQL database.
*/
public DBConnector() {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setUser(conf.getConfigString("username"));
dataSource.setPassword(conf.getConfigString("password"));
dataSource.setServerName(conf.getConfigString("dbhost"));
dataSource.setDatabaseName(conf.getConfigString("dbname"));
dataSource.setPort(conf.getConfigInt("dbport"));
try {
dbConn = dataSource.getConnection();
logger.info("Succesful connection with database!");
} catch (Exception ex) {
logger.info("Error: DBConnector(): problem creating database connection");
}
logger.info("Database connection = " + dbConn);
}