aspose file tools*
The moose likes Servlets and the fly likes jsp connection to access db Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp connection to access db" Watch "jsp connection to access db" New topic
Author

jsp connection to access db

monica acerra
Greenhorn

Joined: Mar 26, 2001
Posts: 6
My first try at connecting db... I have set up my odbc connection in the data source admin,and I have given my data source a name.
I think my problem is in my jsp
<%
Class.forName("sun.jdbc.odbc.Driver");
java.sql.Connection connection = java.sql.DriverManager.getConnection(
"jdbc dbc:c:/tomcat/webapps/examples/jsp/monicaAcerra/ma");
java.sql.Statement statement = connection.createStatement();
java.sql.ResultSet columns = statement.executeQuery(
"SELECT * FROM url");
while(columns.next()) {
String name = columns.getString("name");
String url = columns.getString("url");
%>
<tr>
<td><%= name %></td>
<td><%= url %></td>
</tr>
<% } %>
TIA
Monica
vaibhav punekar
Ranch Hand

Joined: Jan 20, 2001
Posts: 134
java.sql.Connection connection = java.sql.DriverManager.getConnection(
"jdbc dbc:c:/tomcat/webapps/examples/jsp/monicaAcerra/ma)
What is this c:/tomcat/webapps/examples/jsp/......?
I think you need to provide DSN name after odbc:......
Is it your DSn name or the path?
I m sorry I did not get it?


VAIBHAV <BR>SCJP
monica acerra
Greenhorn

Joined: Mar 26, 2001
Posts: 6
I fixed type-o and I guess my dns should just look like:
java.sql.Connection connection = java.sql.DriverManager.getConnection(
"jdbc dbc:ma");
,,,,
my errors are:
ERROR 505
javax.servlet.ServletException: Unable to load class sun.jdbc.odbc.Driver
,,
java.lang.ClassNotFoundException: Unable to load class sun.jdbc.odbc.Driver
TIA,
Monica
k b
Greenhorn

Joined: Feb 01, 2001
Posts: 22
You may have to put the zip file for the driver
sun.jdbc.odbc.Driver
into the lib directory.
Try this.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Monica,
I think the Driver name is, "sun.jdbc.odbc.JdbcOdbcDriver". Please change it and see.
regds
maha anna
monica acerra
Greenhorn

Joined: Mar 26, 2001
Posts: 6
yes sun.jdbc.odbc.JdbcOdbcDriver was correct!! YES!!!
I was thinking that maybe I should have imported classes like sql. or util. Why not??
Monica
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp connection to access db