-
1. Re: Connecting to MySQL
jonlee Dec 9, 2003 12:31 AM (in response to gregsmith)Did you put the MySQL JDBC driver JAR in JBOSS_HOME/server/default/lib or whatever is appropriate for your run-time instance - normally default is the run-time instance unless you override the bootstrap with an option for run.sh.
-
2. Re: Connecting to MySQL
gregsmith Dec 9, 2003 6:46 AM (in response to gregsmith)Yes. I put mysql-java-connector-java-3.0.9-stable.bin.jar in JBOSS_HOME/server/default/lib
greg -
3. Re: Connecting to MySQL
jonlee Dec 9, 2003 7:54 AM (in response to gregsmith)My bad. I've misinterpreted what you are trying to achieve.
I assume that code fragment is what you are using to try and connect? Should that be the case, it won't work because the DataSource is the containing object for connections.
In order to use the connection pool declared, you need to lookup the datasource and then use the connection issued from the datasource. You can only access the DataSource by performing a JNDI lookup from within the JVM that JBoss is running.DataSource ds = (new InitialContext()).lookup("java:/DefaultDS"); Connection connection = ds.getConnection(); // get connection from datasource (connection pool) ... connection.close(); // release connection back to pool
Hope that helps. -
4. Re: Connecting to MySQL
jonlee Dec 9, 2003 8:34 AM (in response to gregsmith)A slight mistake in the first line. The lookup returns an object which you should cast as a DataSource.