aspose file tools*
The moose likes JDBC and the fly likes newbie help: Database server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "newbie help: Database server" Watch "newbie help: Database server" New topic
Author

newbie help: Database server

mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
i have MS Access database installed on my windows 95 box.
would it be ok to do jdbc programming with it ? are there any special steps needed ?
the jdbc tutorial is with the Cloudscape database. would the tutorial be compatible with MS Access ?
[ February 25, 2002: Message edited by: mark stone ]
mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
REPOSTING.........
Originally posted by mark stone:
i have MS Access database installed on my windows 95 box.
would it be ok to do jdbc programming with it ? are there any special steps needed ?
the jdbc tutorial is with the Cloudscape database. would the tutorial be compatible with MS Access ?
[ February 25, 2002: Message edited by: mark stone ]
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
there is no problem accesing an access database.
you can use the JDBC_ODBC bridge for that like this:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:"your dsn name here");
you need to make a system or file dsn for the database.
for that u need to go in the control panel and to ODBC datasources, and add there your mdb file with a dsn name.
[ Edited by Dave to fix the ]
[ February 25, 2002: Message edited by: David O'Meara ]
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Try using this connection to connect to access. There is no set up for the DSN. The compatibility issues are stated in the code comments. Also, when you change the code to replace my information with yours, you MUST PRESERVE the spacing between the different parts of the ODBC connection string.

Jamie
mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
well the drivers tab does indicate a ms access driver (*.mdb) with a version number. so do i need to add something or edit something here, ie in the settings for odbc in control panel ?
or if the driver version is there, all is fine.
next the file that you mention as under c:\temp\data\emp.mdb , i gues this refers to the database that i need to have. right ? and our java program would connect or try to connect to this database. right ? (with username Admin, as we write in our program ? right ?

if this is all ok, then i am all set to proceeed with jdbc programming. right ?
if i have missed out anything ,then please let me know as i can correct it now.
Originally posted by Jamie Robertson:
Try using this connection to connect to access. There is no set up for the DSN. The compatibility issues are stated in the code comments. Also, when you change the code to replace my information with yours, you MUST PRESERVE the spacing between the different parts of the ODBC connection string.

Jamie
Tetsuo Suzuki
Greenhorn

Joined: Feb 21, 2002
Posts: 22
I had similar questions - I wanted to connect to Access and SQL Server using JDBC and did so successfully with the JDBC-ODBC bridge but found out that the driver pretty much sucks (connection /resultset) limitations etc...
If you want a great driver for free try out the Opta drivers from Inet Software. When you download them there is a sample .java file that pretty much explains how to get connected.
Tetsuo!
[ February 26, 2002: Message edited by: Tetsuo Suzuki ]
mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
well i have access installed ok on my windows 95 box. and under the control panel>>odbc(32) under the drivers tab i can see the access driver with version number fine.
now under File DSN tab do we need to go and add a new data source ? or we don't need to do anything with this part ?
please let me know as i am pretty much stuck with this.

suzuki : right now i just want to learn and performance and speed etc can take a backseat. so you are saying that inetsoft makes drivers for other companies databases ? i don't think they would have access to their proprietary code.
anyway thanks for the tip. any installation gotchas with driver install ?
[ February 26, 2002: Message edited by: mark stone ]
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by mark stone:
[QB]well the drivers tab does indicate a ms access driver (*.mdb) with a version number. so do i need to add something or edit something here, ie in the settings for odbc in control panel ?
If you are showing that the version 4.0 and up, then that is all you have to do.

next the file that you mention as under c:\temp\data\emp.mdb , i gues this refers to the database that i need to have. right ?
yes, this is the database that I connect to. You can connect to a different database in a different directory, just change the string to "C:\\directory\\myDatabase.mdb" to point to your database.
and our java program would connect or try to connect to this database. right ? (with username Admin, as we write in our program ? right ?
Yes, this is the username and password for the database. If you don't create any security, Admin is the default.

if this is all ok, then i am all set to proceeed with jdbc programming. right ?
if i have missed out anything ,then please let me know as i can correct it now.
This is all you need to connect to the database. You don't need to set up the database DSN or anything. JDBC-ODBC tends to be a little finicky, so if you have any further problems, post again.
Jamie
mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
the example given at the sun site
http://developer.java.sun.com/developer/onlineTraining/Database/JDBCShortCourse/jdbc/jdbc.html#jdConnecting
has an example for text file as ODBC data source.
all this confusion is really getting too much for me. why has it been so confusing ? now why do we need this text file as source. what about the actual database of access database ?
Originally posted by Jamie Robertson:
This is all you need to connect to the database. You don't need to set up the database DSN or anything. JDBC-ODBC tends to be a little finicky, so if you have any further problems, post again.
Jamie
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Maybe I'm confusing you by trying to making the connection procedure different. This connection String is not documented anywhere, I haven't found any documentation that supports this connection, but it works!
So while at the java tutorials, they assume that you have to
1. set up your DSN
2. make your connections using the connection strings they provided.

OR you can use my code and
1. Connect with the ODBC connection string I have shown in my code (or modified to fit your database/path/password)
Using my technique, you would connect like(connection code take from your link):

So just pick one or the other. Once you have your connection, you can proceed to write your code.
Is there any part that I can help make more clear? Have you tried to connect yet?
Jamie
[ February 27, 2002: Message edited by: Jamie Robertson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: newbie help: Database server
 
Similar Threads
How to build DSN on the fly for MS Access database JDBC access?
Question regarding the Database for my webproject.
ODBC-JDBC bridge?
JDBC driver for MS Access (Linux)
many-to-many relationship