Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

database access in JSP

0 views
Skip to first unread message

Darren

unread,
Jun 8, 2001, 2:17:31 PM6/8/01
to
i am using win2000 professional and access 2000

where should i create the DSN? in system dsn or user dsn?
i have set the ODBC config in both System DSN and User DSN,
but still can't access the database...
the following error comes out:


Error: 500
Location: /myowndir/app1/testdb1.jsp
Internal Servlet Error:

javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver]
Microsoft Jet ????????????????? 'moliu1'??????????????????
at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:459)
at
app_00031._0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_7._jspServic
e(_0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_7.java:97)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:177)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)

Root cause:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Microsoft
Jet ????????????????? 'moliu1'??????????????????
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2494)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:314)
at
sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:229)
at
app_00031._0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_7._jspServic
e(_0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_7.java:70)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:177)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)


i use the following to connect the database:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:APP1");

APP1 is the DSN, what's the problem?

thank you!!


Darren

unread,
Jun 8, 2001, 2:59:46 PM6/8/01
to
sorry...
the previous error should be:

Error: 500
Location: /myowndir/app1/testdb1.jsp
Internal Servlet Error:

javax.servlet.ServletException


at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:459)
at

app_00031._0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_8._jspServic
e(_0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_8.java:97)

Root cause:
java.sql.SQLException
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:285)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:376)
at
app_00031._0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_8._jspServic
e(_0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_8.java:78)

Lee Fesperman

unread,
Jun 8, 2001, 4:34:14 PM6/8/01
to
Darren wrote:
>
> sorry...
> the previous error should be:
> ....

>
> Root cause:
> java.sql.SQLException
> at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:285)
> at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:376)
> at
> app_00031._0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_8._jspServic
> e(_0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_8.java:78)

This is the essential part. Unfortunately, it doesn't show the text of the SQLException.
It does show the error occurred on a call to getString() in java.sql.ResultSet.

If you post the relevant code .... where you are doing the getString() calls ... someone
may be able to help you.

--
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
===================================================================
* Check out Database Debunkings (http://www.firstsql.com/dbdebunk/)
* "The Forum Where Database Matters Are Set Straight"

Darren

unread,
Jun 9, 2001, 6:03:54 AM6/9/01
to
HERE ARE THE CODES:

<html>
<head>
<title>display database data</title>
</head>
<%@ page import="java.sql.*" %>

<body>

<h1 align=center>display data</h1>
<table border=1 align=center>
<tr><th>USERNAME<th>PASSWORD<th>FULL NAME<th>COMMENT</tr>
<%


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:APP1");

Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select UID, PWD, Fname, Lname, Comment from
User");

while(rs.next())
{
String moUID=rs.getString("UID");
String moPWD=rs.getString("PWD");
String moFname=rs.getString("Fname");
String moLname=rs.getString("Lname");
String moComment=rs.getString("Comment");

out.print("<tr>");
out.print("<td>" + moUID + "</td>");
out.print("<td>" + moPWD + "</td>");
out.print("<td>" + moFname + " " + moLname + "</td>");
out.print("<td>" + moComment + "</td>");
out.print("</tr>");
}

con.close();
%>
</table>

</body>
</html>

THX!!!


tom

unread,
Jun 11, 2001, 10:16:56 AM6/11/01
to
try changing the getString calls .

try useing column numbers.


: <html>


: <head>
: <title>display database data</title>
: </head>
: <%@ page import="java.sql.*" %>
:
: <body>
:
: <h1 align=center>display data</h1>
: <table border=1 align=center>
: <tr><th>USERNAME<th>PASSWORD<th>FULL NAME<th>COMMENT</tr>
: <%
: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
: Connection con=DriverManager.getConnection("jdbc:odbc:APP1");
:
: Statement stmt=con.createStatement();
: ResultSet rs=stmt.executeQuery("select UID, PWD, Fname, Lname, Comment
from
: User");
:
: while(rs.next())
: {

: String moUID=rs.getString(1);
: String moPWD=rs.getString(2);
: String moFname=rs.getString(3);
: String moLname=rs.getString(4);
: String moComment=rs.getString(5);
:
: out.print("<tr>");


: out.print("<td>" + moUID + "</td>");
: out.print("<td>" + moPWD + "</td>");
: out.print("<td>" + moFname + " " + moLname + "</td>");
: out.print("<td>" + moComment + "</td>");
: out.print("</tr>");
: }
:
: con.close();
: %>
: </table>
:
: </body>
: </html>

"Darren" <darr...@hotmail.com> wrote in message
news:9fss9o$hco$1...@justice.csc.cuhk.edu.hk...
: HERE ARE THE CODES:

:
:


Darren

unread,
Jun 11, 2001, 10:43:51 AM6/11/01
to
still fail...what's the problem????
pls help!!!

i've searched the documentation of tomcat but couldn't find any clues...


tom

unread,
Jun 11, 2001, 11:28:58 AM6/11/01
to
post your error messages. Not a tomcat problem if you can execute a
helloworld example.


"Darren" <darr...@hotmail.com> wrote in message

news:9g2leh$qat$1...@justice.csc.cuhk.edu.hk...
: still fail...what's the problem????

:
:


Darren

unread,
Jun 11, 2001, 1:43:44 PM6/11/01
to
error message:

Error: 500
Location: /myowndir/app1/testdb1.jsp
Internal Servlet Error:

javax.servlet.ServletException
at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:459)
at

app_00031._0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_20._jspServi
ce(_0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_20.java:98)

Root cause:


java.sql.SQLException
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:285)
at

app_00031._0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_20._jspServi
ce(_0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_20.java:78)


"tom" <removethisfi...@iname.com> 撰寫於郵件
news:9g2o2k$phh$1...@bunyip.cc.uq.edu.au...

Robert Klemme

unread,
Jun 12, 2001, 2:09:55 PM6/12/01
to

Lee Fesperman schrieb:


>
> Darren wrote:
> >
> > sorry...
> > the previous error should be:
> > ....
> >
> > Root cause:
> > java.sql.SQLException
> > at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:285)
> > at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:376)
> > at
> > app_00031._0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_8._jspServic
> > e(_0002fapp_00031_0002ftestdb_00031_0002ejsptestdb1_jsp_8.java:78)
>
> This is the essential part. Unfortunately, it doesn't show the text of the SQLException.
> It does show the error occurred on a call to getString() in java.sql.ResultSet.
>
> If you post the relevant code .... where you are doing the getString() calls ... someone
> may be able to help you.

maybe you first check the database whether the table has a string column
where you expect it.

another option is that you did not iterate properly through the result
set.

robert

--
Robert Klemme
Software Engineer
-------------------------------------------------------------
myview technologies GmbH & Co. KG
Riemekestraße 160 ~ D-33106 Paderborn ~ Germany
E-Mail: mailto:robert...@myview.de
Telefon: +49/5251/69090-321 ~ Fax: +49/5251/69090-399
-------------------------------------------------------------

0 new messages