Archive for the ‘jdbc’ Category.

Way to Struts 1.2 DataSource

hurray

Today I had downloaded struts 1.2.7 and tried to write an application. (I know I am selecting a bit old.) I configured the datasource in struts. Alas. When I tried to start my server, tomcat 6.0, I got the error saying "java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource". With Googling I found struts-legacy.jar need to downloaded and copied to lib folder of Tomcat. (I couldnt get the recent version of struts-legacy. I found something in archive). Happily restarted the server. I saw java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool.. oof.. again I need to download commons-dbcp-1.2.2.jar and commons-pool.jar.

My search come to an end :) It is working fine now.

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

kuttikaranam

Today I had a new install of Mandriva 2008 linux. I wrote a java code to test the mysql connectivity. It ended with the following exception.

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.

Alas, deeper google search gives me a solution that told about the mysql connectivity parameter in /etc/my.cnf

skip-networking

This parameter has been added for some security related reasons. Really I dont know what it is. I just removed that line, which solved this issue.

How to access MS Access database from JDBC?

btw, I dint test it. I just post it for my reference. thanks Angsuman Chakraborty.

How to access MS Access database from JDBC?

 private static final String accessDBURLPrefix = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";   private static final String accessDBURLSuffix = ";DriverID=22;READONLY=false}";   // Initialize the JdbcOdbc Bridge Driver   static { try {  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(ClassNotFoundException e) {  System.err.println("JdbcOdbc Bridge Driver not found!"); }} /** Creates a Connection to a Access Database */public static Connection getAccessDBConnection(String filename) throws SQLException{ filename = filename.replace('\\', '/').trim(); String databaseURL = accessDBURLPrefix + filename + accessDBURLSuffix; // System.err.println("Datebase URL: " + databaseURL); return DriverManager.getConnection(databaseURL, "", "");}