Hi There,
I have the following code, where i initialize the dbcp at the end when i
call datasource.GetConnection() i get an MySQLSyntaxErrorException
saying Access denied for user ''@'localhost' to database 'sna_web'
Looking at the error it seems like the pool have lost the auth information
to connect to the datasource like the Username and Password, because the
username is not mentioned in the error. Has anyone had this problem before
or have seen it? any help is greatly appreciated.
Nayana
MySqlProp mysqlprop;
mysqlprop = new
MySqlProp(PropBase.class.getResourceAsStream("mysql.properties"));
Properties props = new Properties();
props.setProperty("Username",
mysqlprop.getProperty(MySqlProp.USERNAME));
props.setProperty("Password",
mysqlprop.getProperty(MySqlProp.PASSWORD));
ConnectionFactory connectionFactory =
new DriverConnectionFactory(new com.mysql.jdbc.Driver(),
mysqlprop.getProperty(MySqlProp.CONSTRING),
props);
KeyedPoolableObjectFactory kpf = new
BaseKeyPoolObjectFactory();
ObjectPool op = new GenericObjectPool();
KeyedObjectPoolFactory pbpf = new
GenericKeyedObjectPoolFactory(kpf);
Collection initsql = new ArrayList();
poolableConnectionFactory =
new PoolableConnectionFactory(connectionFactory, op, pbpf,
"SELECT VERSION()", initsql, true, true);
connectionPool =
new GenericObjectPool(poolableConnectionFactory);
dataSource = new PoolingDataSource(connectionPool);