|
-
August 16th, 1999, 06:06 AM
#1
java Database connection
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 dbc: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
-
August 17th, 1999, 10:36 AM
#2
Re: java Database connection
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!!!
-
August 19th, 1999, 06:42 AM
#3
Re: java Database connection
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.
-
August 22nd, 1999, 11:05 AM
#4
Re: java Database connection
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
-
August 22nd, 1999, 11:37 PM
#5
Re: java Database connection
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.
-
August 22nd, 1999, 11:54 PM
#6
Re: java Database connection
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
-
August 23rd, 1999, 12:05 AM
#7
Re: java Database connection
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
-
August 23rd, 1999, 12:21 AM
#8
Re: java Database connection
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
-
August 30th, 1999, 12:17 AM
#9
Re: java Database connection
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 dbc:"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
#10
Re: java Database connection
Your problem is not the ODBC datasource... it is the typo
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
NOT
Class.forName("sun.jdbc.odbc.JdbcOdbc"):
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|