• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

database connectivity

 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
plz some one answer me!!!
it urgent.
Regards.
 
parul patidar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pranit,
can u tell plz how to connect to system DSN?
Thanks.
 
Pranit Saha
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pranit,
finally I have got it...
saying "Thank you" cannot express my appreciation...
Regards,
mac.
 
Pranit Saha
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic