Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" java.sql.SQLException:

 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey I am facing the below mentioned problems.. so pls see it and let me know.

My programme is this
import java.sql.*;
public class accbase1
{
public static void main(String args[]) throws ClassNotFoundException,SQLException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbcdbc:accdsn");
Statement st=cn.createStatement();
int n=st.executeUpdate("create table students1(sno integer primary key,sname text(20),courses text(30))");
if( n == -1 )
System.out.println("table is created..");

st.close();
cn.close();

}
}



And I am getting this exception

D:\EX\jdbc>javac accbase2.java

D:\EX\jdbc>java accbase2
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3074)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:3
23)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at accbase2.main(accbase2.java:7)
 
Scott Selikoff
author
Saloon Keeper
Posts: 4010
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well for starts, the stack trace indicates the problem is with your getConnection() line so everything after that is irrelevant.

If I had to guess I'd say your ODBC entry was not set up to access the proper access file, although I'm not an ODBC person (no chance you could use a real db?) so someone else will have to take a shot.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Follow this link Connecting to a Database with JDBC
Hope it will helpful to you.
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Scott Selikoff:
Well for starts, the stack trace indicates the problem is with your getConnection() line so everything after that is irrelevant.

If I had to guess I'd say your ODBC entry was not set up to access the proper access file, although I'm not an ODBC person (no chance you could use a real db?) so someone else will have to take a shot.



Yes Sir,

I did create the dsn name and i run the same programme some time back.. but it is not working now... please help me out
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic