inventory databasing

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 = "jdbc:eek:dbc:" + 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
 
I

IchBin

lalalala said:
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 = "jdbc:eek:dbc:" + 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

That looks like you have not defined the Data source to the "ODBC Data
source Administrator".

Personally, I would not code against a Ms Access Database. Since you
have a choice I would use say HSQLDB. This can be found at

http://hsqldb.org

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top