wood burning stoves*
The moose likes JDBC and the fly likes database connectivity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "database connectivity" Watch "database connectivity" New topic
Author

database connectivity

Jimi Rock
Ranch Hand

Joined: Feb 19, 2001
Posts: 134
Hi all,
I have an Access database and jdk 1.3. I want to query my database through a jsp page using beans.
what I need to connect to my database? any separate installation is required in order to use jdbc?
Regards,
mac.
Jimi Rock
Ranch Hand

Joined: Feb 19, 2001
Posts: 134
plz some one answer me!!!
it urgent.
Regards.
parul patidar
Ranch Hand

Joined: Sep 07, 2001
Posts: 53
no seperate installation as long as u r willing to use jdbc.odbc.JdbcOdbcDriver
u need to import java.sql package
and load sun.jdbc.odbc.JdbcOdbcDriver using Class.forName()
Jimi Rock
Ranch Hand

Joined: Feb 19, 2001
Posts: 134
Hi,
thanks for reply.
can u provide me with the segment of code that will do the connection part?
Regards.
mac.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
here is an example from one of my books....

try
{
// Load the driver class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Define the data source for the driver
String sourceURL = "jdbc dbc:yourDataSourceName";
// Create a connection through the DriverManager
Connection databaseConnection =
DriverManager.getConnection(sourceURL);
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe);
}
catch(SQLException sqle)
{
System.err.println(sqle);
}
}

------------------
Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Jimi Rock
Ranch Hand

Joined: Feb 19, 2001
Posts: 134
Hi Bosun,
thanks a lot for ur reply...
I have tried the code but have the following error:
"Data source name not found and no default driver specified"
this is may be becauae my connection url. I want to connect to an access database using jsp. servlet engine is tomcat.
what to do then?
Thanks in advance,
mac.
Pranit Saha
Ranch Hand

Joined: Sep 09, 2001
Posts: 130
U have to connect the database with ur frontend through Jdbc/Odbc driver.. and for that u have to use ODBC and connect through System DSN..
Pranit..
Originally posted by Jimi Rock:
Hi Bosun,
thanks a lot for ur reply...
I have tried the code but have the following error:
"Data source name not found and no default driver specified"
this is may be becauae my connection url. I want to connect to an access database using jsp. servlet engine is tomcat.
what to do then?
Thanks in advance,
mac.

Jimi Rock
Ranch Hand

Joined: Feb 19, 2001
Posts: 134
Hi Pranit,
can u tell plz how to connect to system DSN?
Thanks.
Pranit Saha
Ranch Hand

Joined: Sep 09, 2001
Posts: 130
Assuming that u r using Windows.. Go to start->settings->control panel->ODBC drivers->click on system DSN.. and follow the steps as it says.. tell me if u face ne prob
Pranit..
Jimi Rock
Ranch Hand

Joined: Feb 19, 2001
Posts: 134
Hi Pranit,
finally I have got it...
saying "Thank you" cannot express my appreciation...
Regards,
mac.
Pranit Saha
Ranch Hand

Joined: Sep 09, 2001
Posts: 130
It's nice to hear that u've solved ur prob.. U r always welcome..
Pranit..
Originally posted by Jimi Rock:
Hi Pranit,
finally I have got it...
saying "Thank you" cannot express my appreciation...
Regards,
mac.

 
 
subject: database connectivity
 
Similar Threads
read text file and save data into database
my applet can't connect to database
Stupid question (if any could be such)
How can i randomly viewing image on jsp from the database
database in netbeans