Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-05-2007, 06:13 PM
Member
 
Join Date: Jul 2007
Posts: 39
coco is on a distinguished road
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:

Code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbcdbc:TEST");
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?

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:

Code:
Connection conn = DriverManager.getConnection("jdbcdbc:;Driver=Microsoft Access Driver (*.mdb);DBQ=E:/Databases/TestInv.mdb");
I thought the syntax was a little messy looking but I tried it and it didn't work. Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 09:39 AM
Member
 
Join Date: Jul 2007
Posts: 40
toby is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-20-2008, 08:06 PM
Member
 
Join Date: Aug 2008
Posts: 13
herfnai is on a distinguished road
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());


}
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 09-18-2008, 05:07 PM
Member
 
Join Date: Aug 2008
Posts: 32
hungleon88 is on a distinguished road
Can you guys help me connect java to database with driver type 2,3,4.
I only know connect with type1 JDBC-ODBC Bridge (right?).
i use SQL SERVER 2005
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
connect JDBC to offline database nancyhung Database 1 04-12-2008 01:04 AM
Using JDBC to connect to ORACLE database Java Tip Java Tips 0 02-10-2008 01:27 PM
Connect Java application to photo editor syellows Advanced Java 1 11-21-2007 02:09 AM
Problem to connect Database Swamipsn NetBeans 1 08-07-2007 09:13 AM
without restarting the websphere server i need to connect a newly created database satya Enterprise JavaBeans 4 06-05-2007 03:45 AM


All times are GMT +3. The time now is 02:23 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org