L
lalalala
Hi i took a introductory course in java and ive been programming ever
since. Ive been trying to create a database prgm for my company, and i
heard that access was going to be the simplest and most accesable way
to do it. Ive been trying to connect the java to the access database
that i created but i keep getting an error.
Can anyone check my code and see if i did something wrong, or perhaps
give me some insight on where i may be going wrong.
Here is the code:
private Connection conn01 = null;
public void connect(){
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
String databaseName = "invent";
String url = "jdbcdbc:" + databaseName;
String loginName = "Admin";
String password = "lace";
try {
conn01 = DriverManager.getConnection(url, loginName, password);
} catch (SQLException e) {
e.printStackTrace();
}
}
AND IM RECEIVING THIS ERROR
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source
name not found and no default driver specified
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:323)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at allm.test.DBaccess.connect(DBaccess.java:29)
at allm.test.test.main(test.java:15)
java.lang.NullPointerException
at allm.test.DBaccess.isExist(DBaccess.java:60)
at allm.test.test.main(test.java:19)
Exception in thread "main"
any form of help is greatly appreciated.
I'm sitting in my office with writers block.
Thank you
Nadav
since. Ive been trying to create a database prgm for my company, and i
heard that access was going to be the simplest and most accesable way
to do it. Ive been trying to connect the java to the access database
that i created but i keep getting an error.
Can anyone check my code and see if i did something wrong, or perhaps
give me some insight on where i may be going wrong.
Here is the code:
private Connection conn01 = null;
public void connect(){
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
String databaseName = "invent";
String url = "jdbcdbc:" + databaseName;
String loginName = "Admin";
String password = "lace";
try {
conn01 = DriverManager.getConnection(url, loginName, password);
} catch (SQLException e) {
e.printStackTrace();
}
}
AND IM RECEIVING THIS ERROR
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source
name not found and no default driver specified
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:323)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at allm.test.DBaccess.connect(DBaccess.java:29)
at allm.test.test.main(test.java:15)
java.lang.NullPointerException
at allm.test.DBaccess.isExist(DBaccess.java:60)
at allm.test.test.main(test.java:19)
Exception in thread "main"
any form of help is greatly appreciated.
I'm sitting in my office with writers block.
Thank you
Nadav