Click to See Complete Forum and Search --> : java Database connection
August 16th, 1999, 06:06 AM
Hello,
I am using VJ++ 6.0 ,I want to connect to the MS Access Database,I have used
Class.forName("java.jdbc.odbc.JdbcOdbc");
String url = "jdbc:odbc:test";
Connection con = DriverManager.getConnection(url);
for establishing the connectivity with Access Database,but I am getting an exception as java.lang.classNotFoundException:java/jdbc/odbc/JdbcOdbc;
So please tell me how to set the DSN in the 32-bit ODBC Driver from control panel in detail.
waiting for your reply
sachin
DeviPrasad
August 17th, 1999, 10:36 AM
hai,
The following steps are involved in preparing ur database and ur ODBC driver
before executing any SQL statements on it.
1. Create the data base first. Lets call it Marks_Database.mdb assuming that it is an Access Database
2. Now you will have to register this database in ur control panel. For this, go to control panel and double click the 32bit - ODBC icon.
3. Click the "User DSN" tab in the property sheet that pops up. Mostly this will be selected by default for you
4. Click the add button now. This will give u a list of database drivers available.
5. Double click the MSAccess option (if your database is Access). Now you will get a dialog box.
6. Here u can type the datasource name say "My marks at college semesterwise" - note that this need not be the name of your database. Also u can type a description for your database.
7. The last step is to select the database to be associated with this particular driver. U can do this by clicking the "Select" button.
Now ur database is ready to be accessed from ur java code and u should not get that exception again.
thanx,
Devi Prasad M. P.
Keep smiling!!!
Keep working hard!!!
Keep climbing high!!!
Sufyan
August 19th, 1999, 06:42 AM
Hi,
is there anyway to access a database in java without going thro' User DSN .. ???
so if i want to give my applet to someone else to run it on some other m/c .. my installation script will have to create the user DSN ???
In VJ i have heard that u have DAO ... but i dont want to use VJ coz then my applet wont be portable (macs and unix platforms also ) ??
any ideas ????
thanks in anticipation.
- sufyan.
unicman
August 22nd, 1999, 11:05 AM
There is a concept of File DSN. If u can create File DSN instead of User/System DSN, File DSN is just a file with 'dsn' extension. U might be able to copy it on other machine and use it.
- UnicMan
Sufyan
August 22nd, 1999, 11:37 PM
thanks unicman,
any idea where will i get some help on file dsn ??
do u have a .dsn file created, which u could send ???
- sufyan.
unicman
August 22nd, 1999, 11:54 PM
It is simple. There is a tab 'File DSN' when u open ODBC from Control Panel. When u create the File DSN, a file with the dsn name with '.dsn' extension will get created. U can use this file.
- UnicMan
Sufyan
August 23rd, 1999, 12:05 AM
if i use this file, then wiil i have to add it in the control-panel-32 bit ODBC on the target machine ????
where does this file get created ????
- sufyan
unicman
August 23rd, 1999, 12:21 AM
Once u have the file I don't think u will need to add it thro' control-panel.
The file is usually in '\Program Files\Common Files\ODBC\Data Sources'.
- UnicMan
Saran
August 30th, 1999, 12:17 AM
the correct format is
1. u have to use the ODBC to create a new DSN that points to ur Access table
2.the code should be like this...
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver);
Connection con;
con = DriverManager.getConnection("jdbc:odbc:"name of your DSN name as given in ODBC","user name","password");(user name and password are optional)
Statement st = con.createStatement();
String s = "sql stmt";
st.executeUpdate(s);
this is one way to do..
depending on ur requirement, u have to use any one of the statements etc..
September 15th, 1999, 04:17 PM
Your problem is not the ODBC datasource... it is the typo
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
NOT
Class.forName("sun.jdbc.odbc.JdbcOdbc"):
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.