Results 1 to 4 of 4
- 08-05-2007, 04:13 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 39
- Rep Power
- 0
Help with Java application to connect to a database
Hi, I'm trying to write a Java application to connect to a database that resides on our network server. I've been able to connect to the database in question from my client PC using the basic connection code:
I created a DSN on my client computer named TEST that mapped a network drive to the database that I wanted to use. All is well! My question is, since there are a fair number of client computers in my network, how can I rig it so that I can connect to the DSN on the server?Java Code:Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbcdbc:TEST");
I'd really rather not have to create a DSN on every single client computer, and I'm assuming that there is a way to do this, since it would be really dumb if there wasn't. So if anyone can give me the syntax on how to work this, i'd be delighted. I'm connecting to an access database. One site suggested doing this:
I thought the syntax was a little messy looking but I tried it and it didn't work. Thanks.Java Code:Connection conn = DriverManager.getConnection("jdbcdbc:;Driver=Microsoft Access Driver (*.mdb);DBQ=E:/Databases/TestInv.mdb");
- 08-07-2007, 07:39 AM #2
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
There are some extremely talented Java people over at JavaRanch Big Moose Saloon. I'm pretty sure that someone over there will be able to answer about any question that you have.
- 08-20-2008, 06:06 PM #3
Member
- Join Date
- Aug 2008
- Posts
- 13
- Rep Power
- 0
hello you must make odbc and:
Connection cn=null;
Statement stm=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("jdbcdbc:database name");
stm=cn.createStatement(ResultSet.TYPE_SCROLL_SENSI TIVE,
ResultSet.CONCUR_UPDATABLE);
JOptionPane.showMessageDialog(null,"connected");
}catch(Exception e)
{JOptionPane.showMessageDialog(null,"eroor" +"\n"+e.getMessage());
}
- 09-18-2008, 03:07 PM #4
Member
- Join Date
- Aug 2008
- Posts
- 41
- Rep Power
- 0
Similar Threads
-
connect JDBC to offline database
By nancyhung in forum JDBCReplies: 1Last Post: 04-11-2008, 11:04 PM -
Using JDBC to connect to ORACLE database
By Java Tip in forum Java TipReplies: 0Last Post: 02-10-2008, 11:27 AM -
Connect Java application to photo editor
By syellows in forum Advanced JavaReplies: 1Last Post: 11-21-2007, 12:09 AM -
Problem to connect Database
By Swamipsn in forum NetBeansReplies: 1Last Post: 08-07-2007, 07:13 AM -
without restarting the websphere server i need to connect a newly created database
By satya in forum Enterprise JavaBeans (EJB)Replies: 4Last Post: 06-05-2007, 01:45 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks