[jboss-user] [Datasource Configuration] - java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find file
m p
do-not-reply at jboss.com
Fri May 31 10:11:23 EDT 2013
m p [https://community.jboss.org/people/mp_108] created the discussion
"java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find file"
To view the discussion, visit: https://community.jboss.org/message/820693#820693
--------------------------------------------------------------
Background:
I am developing in Eclipse and using Struts 2 framework to build and deploy .war file to http://www.coderanch.com/forums/f-63/JBoss JBoss. 4.2.3GA
There is an action class that I am using to insert a user into a database table - pretty simple stuff http://cache-www.coderanch.com/images/smilies/3b63d1616c5dfcf29f8a7a031aaa7cad.gif http://cache-www.coderanch.com/images/smilies/3b63d1616c5dfcf29f8a7a031aaa7cad.gif
I get the following exception for executeUpdate() method.
DEBUG com.opensymphony.xwork2.DefaultActionInvocation.debug:68 - Executing action method = execute
[STDOUT] >>>>>>>>>>insert into catNav.USERS values('mm', 'pp', 88, 'mm.pp at yahoo.com (mailto:'mm.pp at yahoo.com)');
[STDOUT] java.sql.SQLException (http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.html): [Microsoft][ODBC Microsoft Access Driver] Could not find file *'C:\java\jboss-4.2.3.GA\bin\catNav.mdb'*.
*I am provide the full path to the database .mdb file but the exception is referring to file in jboss folder, which is does no exist. I am struggling to find a solution to resolve this. * The path, using either \\ or / file separators is validated as an exception occurs if invalid path is defined.
The code is below; I have the same code in a standalone Java program that executes successfully (I verify row was added) .... *but fails when running on JBoss* :(
public String execute() throws Exception {
//call Service class to store personBean's state in database
final String dbName = "catNav";
Connection con = null; // The connection to the database.
Statement stmt = null;
// The following code can throw errors, so they must be caught.
try{
// First, tell Java what driver to use and where to find it.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Next, create a connection to your data source.
// Specify that you are using the ODBC-JDBC Bridge.
// And specify the data source name from ODBC.
String database =
"jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Users/mp/Documents/Work/JDBC/catNav.mdb;";
con = DriverManager.getConnection(database, "", "");
/* also tried:
con = DriverManager.getConnection("jdbc:odbc:catNavDB");
*/
// Create an SQL statement.
stmt = con.createStatement();
// Execute some SQL to create a table in your database.
// If the table already exists, an exception is thrown!
String sqlSt = "insert into " + dbName +
".USERS " +
"values('" + personBean.getFirstName() + "', " + // FIRST_NAME
"'" + personBean.getLastName() + "', " + // LAST_NAME
personBean.getAge() + ", " + // AGE
"'" + personBean.getEmail() + "'); " ; // EMAIL
// display SQL statment
System.out.println (">>>>>>>>>>" + sqlSt );
stmt.executeUpdate( sqlSt);
}
// Catch any exceptions that are thrown.
etc.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/820693#820693]
Start a new discussion in Datasource Configuration at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130531/4aba8e42/attachment-0001.html
More information about the jboss-user
mailing list