O poderia fazer para consertar este erro? Já li várias respostas no google, mas nada funciona, alguém teria uma idéia?
Meu código é o seguinte:
import java.sql.;
import java.util.;
import org.gjt.mm.mysql.Driver.*;
public class DBTest
{
public static void main(String args[]) throws Exception
{
try {
new org.recommender.util.pool.JDCConnectionDriver("jdbc:mysql://127.0.0.1/test", "root","");
} catch (Exception e) {
System.out.println("Exception: " + e);
System.out.println("Fatal error: Couldn't initialize sql connection pool");
System.exit(1);
}
}
}
/********************************************************/
/
- Copyright © 2003 Oregon State Universtity. All rights reserved.
*/
package org.recommender.util.pool;
import java.sql.;
import java.util.;
/**
- This class provides a wrapper to other JDBC Drivers that provides for
- connection pooling. The idea of connection pooling is to avoid creating
- new connections to the database as much as possible, as they are costly
- with repsect to performance. Rather, whenever possible, we reuse an existing
- connection to the database. The basis of this class came from
- http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html
- More documentation can be found there.
- Example usage:
static {
try{
new pool.JDCConnectionDriver(“COM.cloudscape.core.JDBCDriver”,
“jdbc:cloudscape:ejbdemo”,“none”, “none”);
} catch(Exception e) {}
}
…
public Connection getConnection() throws SQLException {
return DriverManager.getConnection(“jdbc:jdc:jdcpool”);
}
*
- As shown above, you first initialize the pool, then you use JDBC as usual,
- except that instead of your true sql driver, you specify “jdbc:jdc:jdcpool”
- @author Jon Herlocker
- @see JDCConnection
-
@see JDCConnectionPool
*/
public class JDCConnectionDriver implements Driver {
public static final String URL_PREFIX = "jdbc:jdc:";
private static final int MAJOR_VERSION = 1;
private static final int MINOR_VERSION = 0;
private JDCConnectionPool pool;
public JDCConnectionDriver(String driver, String url,
String user, String password)
throws ClassNotFoundException,
InstantiationException, IllegalAccessException,
SQLException
{
System.out.println(“Aqiui”);
DriverManager.registerDriver(this);
Class.forName(driver).newInstance();
System.out.println(“Aqiui”);
pool = new JDCConnectionPool(url, user, password);
}
public JDCConnectionDriver(String url, String user, String password)
throws ClassNotFoundException, InstantiationException,
IllegalAccessException,SQLException
{
DriverManager.registerDriver(this);
DriverManager.getDriver(url);
pool = new JDCConnectionPool(url, user, password);
}
public Connection connect(String url, Properties props)
throws SQLException {
if(!url.startsWith(URL_PREFIX)) {
return null;
}
return pool.getConnection();
}
public boolean acceptsURL(String url) {
return url.startsWith(URL_PREFIX);
}
public int getMajorVersion() {
return MAJOR_VERSION;
}
public int getMinorVersion() {
return MINOR_VERSION;
}
public DriverPropertyInfo[] getPropertyInfo(String str, Properties props) {
return new DriverPropertyInfo[0];
}
public boolean jdbcCompliant() {
return false;
}
}
Obrigada,
Luciana