You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bruno Armand <na...@yahoo.de> on 2003/09/03 17:01:10 UTC
jdbcodbc database connection problem (access-DB,jsp,tomcat,eclipse)!
Please i try since one week to become this program
without error, but without success. Perrhaps can you
help me!
I write a jsp-file for calling and saving data from an
access existing database which i connect with a
odbc-driver.
The adrList.jsp ist in the directory
c:\eclipse\workspace\projectX\
I try to start it from tomcat with
http://localhost:8080/student.
The file HelloWorld.jsp in the same directory runs
without problem.
Please here are:
1. The code of the adrList.jsp and
2. The displayed errormessage.
__________________________________-
1.
<html>
<head>
<%@ page language="java" import = "java.sql.*" %>
<%@ page import = "java.lang.*" %>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Properties props = new Properties();
props.setProperty("user", "");
props.setProperty("password", "");
String url =
"jdbc:odbc:http://localhost:8080:Bruno_Adress_odbc";
Connection con = DriverManager.getConnection(url,
props);
String sql1 = "INSERT INTO Adressen (Nachname,
Adresse," +
" Postleitzahl, Land, Ort)" +
" VALUES ('Bruno Armando', 'Am Vaihingen 20',
'70187', " +
"'Deutschland', 'Stuttgart')";
String sql2 = "INSERT INTO Adressen (Nachname,
Adresse,"+
" Postleitzahl, Land, Ort) " +
"VALUES ('Becker Marlise', 'Koenigstr 78', '70174',
"+
"'Deutschland', 'Stuttgart')";
String query = "SELECT * FROM Adressen";
Statement stmt = con.createStatement();
stmt.executeUpdate(sql1);
stmt.executeUpdate(sql2);
ResultSet rs = stmt.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
%>
<title>Details-Adressen von den 5 Besten</title>
</head>
<BODY>
<TABLE width='80%' border=0 align='center'
cellSpacing=5 cellPadding=2 bgcolor="#0000FF"
bordercolor="#000000">
<tr>
<TD align=left> </TD>
<TD align=right >
</TD>
<td> Name</td>
<td> Street</td>
<td> Zip</td>
<td> Town</td>
<td> Country</td>
</tr>
<%
while (rs.next())
{
%>
<tr>
<TD align=left> </TD>
<TD align=right > </TD>
<%
for (int i = 2; i <= columnCount; i++)
%>
<td>
<% = rs.getString(i) %>
</td>
<%
}
%>
</tr><br>
<%
}
rs.close();
stmt.close();
con.close();
}
catch (SQLException ex)
{
System.out.println("SQLException:");
while (ex != null)
{
System.out.println("SQLState: " +
ex.getSQLState());
System.out.println("Nachricht: " +
ex.getMessage());
System.out.println("Anbieter: " +
ex.getErrorCode());
ex = ex.getNextException();
System.out.println("");
}
%>
</table>
</body>
</html>
2. Errormessage:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error
() that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile
class for JSP
An error occurred at line: 106 in the jsp file:
/adrList.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Programme\Apache Group\Tomcat
4.1\work\Standalone\localhost\student2\adrList_jsp.java:159:
illegal start of expression
= rs.getString(i)
^
An error occurred at line: 14 in the jsp file:
/adrList.jsp
Generated servlet error:
C:\Programme\Apache Group\Tomcat
4.1\work\Standalone\localhost\student2\adrList_jsp.java:58:
'try' without 'catch' or 'finally'
try
^
An error occurred at line: 112 in the jsp file:
/adrList.jsp
Generated servlet error:
C:\Programme\Apache Group\Tomcat
4.1\work\Standalone\localhost\student2\adrList_jsp.java:186:
illegal start of expression
public static Connection getConnection()
^
An error occurred at line: 14 in the jsp file:
/adrList.jsp
Generated servlet error:
C:\Programme\Apache Group\Tomcat
4.1\work\Standalone\localhost\student2\adrList_jsp.java:61:
cannot resolve symbol
symbol : method getConnection ()
location: class org.apache.jsp.adrList_jsp
Connection con = getConnection();
^
An error occurred at line: 112 in the jsp file:
/adrList.jsp
Generated servlet error:
C:\Programme\Apache Group\Tomcat
4.1\work\Standalone\localhost\student2\adrList_jsp.java:170:
cannot resolve symbol
symbol : variable rs
location: class org.apache.jsp.adrList_jsp
rs.close();
^
An error occurred at line: 112 in the jsp file:
/adrList.jsp
Generated servlet error:
C:\Programme\Apache Group\Tomcat
4.1\work\Standalone\localhost\student2\adrList_jsp.java:171:
cannot resolve symbol
symbol : variable stmt
location: class org.apache.jsp.adrList_jsp
stmt.close();
^
An error occurred at line: 112 in the jsp file:
/adrList.jsp
Generated servlet error:
C:\Programme\Apache Group\Tomcat
4.1\work\Standalone\localhost\student2\adrList_jsp.java:172:
cannot resolve symbol
symbol : variable con
location: class org.apache.jsp.adrList_jsp
con.close();
^
7 errors
at
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
________________________
Thank!
Bruno!
__________________________________________________________________
Gesendet von Yahoo! Mail - http://mail.yahoo.de
Logos und Klingeltöne fürs Handy bei http://sms.yahoo.de
Re: jdbcodbc database connection problem (access-DB,jsp,tomcat,eclipse)!
Posted by Jon Wingfield <jo...@mkodo.com>.
My German's not that good but BabelFish returned the error as
"That Data source name was not found, and no standard driver was indicated."
So, i guess, your ODBC data source is not set up correctly or you are
using the wrong name (maybe case-sensitive). I can't help you with that,
i'm afraid, because it's about 5 years (and about 4 windows versions)
since i've tried it. Linux and mysql for me recently :)
Here's a couple of Sun's online JDBC tutorials:
http://java.sun.com/docs/books/tutorial/jdbc/index.html
http://developer.java.sun.com/developer/onlineTraining/Database/JDBCShortCourse/contents.html
Jon
Bruno Armand wrote:
> Hello Jon,
>
> In the file tomcat../log/stdout,
> this error information can be found:
> "
> SQLException:
> SQLState: IM002
> Nachricht: [Microsoft][ODBC Driver Manager] Der
> Datenquellenname wurde nicht gefunden, und es wurde
> kein Standardtreiber angegeben.
> Anbieter: 0
> there was error
> "
>
> By testing myself, i realise that, after the
> Connection con = .... statement, no html-code can be
> displayed. But before it, it`s possible.
> The problem is now to know to make the connection to
> the database correctly. But at this level, i don`t
> have so many experience, only because i am a
> beginner...
>
> I hope you understand what i mind.
>
> Thank!
>
> Bruno
>
Re: jdbcodbc database connection problem (access-DB,jsp,tomcat,eclipse)!
Posted by Bruno Armand <na...@yahoo.de>.
Hello Jon,
In the file tomcat../log/stdout,
this error information can be found:
"
SQLException:
SQLState: IM002
Nachricht: [Microsoft][ODBC Driver Manager] Der
Datenquellenname wurde nicht gefunden, und es wurde
kein Standardtreiber angegeben.
Anbieter: 0
there was error
"
By testing myself, i realise that, after the
Connection con = .... statement, no html-code can be
displayed. But before it, it`s possible.
The problem is now to know to make the connection to
the database correctly. But at this level, i don`t
have so many experience, only because i am a
beginner...
I hope you understand what i mind.
Thank!
Bruno
--- Jon Wingfield <jo...@mkodo.com> schrieb:
> Very difficult to tell ;)
>
> Do you have any errors in the tomcat logs?
> Does your debug in the SQLException catch clause get
> written to std out
> or catalina.out?
> If a SQLException did get thrown during the
> inserts/select the output
> would be:
>
> <html>
> <head>
> </table>
> </body>
> </html>
>
> Not quite sure how that would be rendered in a
> browser.
>
> Are you sure you can load the jdbc driver? A
> ClassNotFoundException can
> be thrown from Class.forName(...)
>
> Are you sure you are getting a connection to the
> database? Is your
> connection url correct? Also, the JdbcOdbcBridge has
> always been flaky
> at best.
>
>
> I would recommend removing as much java code as
> possible from the jsp
> and use Beans or taglibs for the database access. It
> should make the jsp
> code a lot cleaner. For another thing it makes
> testing a lot easier :)
>
> HTH,
>
> Jon
>
> Bruno Armand wrote:
>
> > Now,
> >
> > i correct all the errors (As you see n the code
> > below), but the jsp-page ist displayed, but
> without
> > anything written (from html or database.). Can you
> > know why please?
> >
> > Thank!
> >
> > --- Jon Wingfield <jo...@mkodo.com>
> schrieb:
> >
> >>try
> >><%= rs.getString(i) %>
> >>instead of
> >><% = rs.getString(i) %>
> >>
> >>
> >>Bruno Armand wrote:
> >>
> >>
> >>>Please i try since one week to become this
> program
> >>>without error, but without success. Perrhaps can
> >>
> >>you
> >>
> >>>help me!
> >>>
> >>>I write a jsp-file for calling and saving data
> >>
> >>from an
> >>
> >>>access existing database which i connect with a
> >>>odbc-driver.
> >>>The adrList.jsp ist in the directory
> >>>c:\eclipse\workspace\projectX\
> >>>I try to start it from tomcat with
> >>>http://localhost:8080/student.
> >>>The file HelloWorld.jsp in the same directory
> runs
> >>>without problem.
> >>>
> >>>Please here are:
> >>>1. The code of the adrList.jsp and
> >>>2. The displayed errormessage.
> >>>__________________________________-
> >>>1.
> >>><html>
> >>><head>
> >>><%@ page language="java" import = "java.sql.*" %>
> >>><%@ page import = "java.lang.*" %>
> >>><%
> >>>try
> >>>{
> >>> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> >
> > String username = "";
> > String password = "";
> > String url = "jdbc:odbc:Bruno_Adress_odbc";
> > Connection con =
> DriverManager.getConnection(url,
> > username,password);
> >
> >
> >>>String sql1 = "INSERT INTO Adressen (Nachname,
> >>>Adresse," +
> >>> " Postleitzahl, Land, Ort)" +
> >>> " VALUES ('Bruno Armando', 'Am Vaihingen 20',
> >>>'70187', " +
> >>>"'Deutschland', 'Stuttgart')";
> >>>
> >>>String sql2 = "INSERT INTO Adressen (Nachname,
> >>>Adresse,"+
> >>> " Postleitzahl, Land, Ort) " +
> >>> "VALUES ('Becker Marlise', 'Koenigstr 78',
> >>
> >>'70174',
> >>
> >>>"+
> >>>"'Deutschland', 'Stuttgart')";
> >>>
> >>>String query = "SELECT * FROM Adressen";
> >>>
> >>>Statement stmt = con.createStatement();
> >>>
> >>>stmt.executeUpdate(sql1);
> >>>stmt.executeUpdate(sql2);
> >>>ResultSet rs = stmt.executeQuery(query);
> >>>ResultSetMetaData rsmd = rs.getMetaData();
> >>>int columnCount = rsmd.getColumnCount();
> >>>%>
> >>>
> >>><title>Details-Adressen von den 5 Besten</title>
> >>></head>
> >>><BODY>
> >>>
> >>><TABLE width='80%' border=0 align='center'
> >>>cellSpacing=5 cellPadding=2 bgcolor="#0000FF"
> >>>bordercolor="#000000">
> >>><tr>
> >>><TD align=left> </TD>
> >>> <TD align=right >
> >>>
> >>> </TD>
> >>>
> >>><td> Name</td>
> >>><td> Street</td>
> >>><td> Zip</td>
> >>><td> Town</td>
> >>><td> Country</td>
> >>></tr>
> >>>
> >>><%
> >>>while (rs.next())
> >>>{
> >>>%>
> >>><tr>
> >>> <TD align=left> </TD>
> >>> <TD align=right > </TD>
> >>><%
> >>> for (int i = 2; i <= columnCount; i++)
> >>>%>
> >>> <td>
> >>> <%= rs.getString(i) %>
> >>> </td>
> >>><%
> >>>}
> >>>%>
> >>></tr><br>
> >>><%
> >>>}
> >>>rs.close();
> >>>stmt.close();
> >>>con.close();
> >>>}
> >>>catch (SQLException ex)
> >>>{
> >>> System.out.println("SQLException:");
> >>> while (ex != null)
> >>> {
> >>> System.out.println("SQLState: " +
> >>>ex.getSQLState());
> >>> System.out.println("Nachricht: " +
> >>>ex.getMessage());
> >>> System.out.println("Anbieter: " +
> >>>ex.getErrorCode());
> >>> ex = ex.getNextException();
> >>> System.out.println("");
> >>>}
> >
> > }
> >
> >>>%>
> >>></table>
> >>></body>
> >>></html>
>
=== message truncated ===
__________________________________________________________________
Gesendet von Yahoo! Mail - http://mail.yahoo.de
Logos und Klingeltöne fürs Handy bei http://sms.yahoo.de
Re: jdbcodbc database connection problem (access-DB,jsp,tomcat,eclipse)!
Posted by Jon Wingfield <jo...@mkodo.com>.
Very difficult to tell ;)
Do you have any errors in the tomcat logs?
Does your debug in the SQLException catch clause get written to std out
or catalina.out?
If a SQLException did get thrown during the inserts/select the output
would be:
<html>
<head>
</table>
</body>
</html>
Not quite sure how that would be rendered in a browser.
Are you sure you can load the jdbc driver? A ClassNotFoundException can
be thrown from Class.forName(...)
Are you sure you are getting a connection to the database? Is your
connection url correct? Also, the JdbcOdbcBridge has always been flaky
at best.
I would recommend removing as much java code as possible from the jsp
and use Beans or taglibs for the database access. It should make the jsp
code a lot cleaner. For another thing it makes testing a lot easier :)
HTH,
Jon
Bruno Armand wrote:
> Now,
>
> i correct all the errors (As you see n the code
> below), but the jsp-page ist displayed, but without
> anything written (from html or database.). Can you
> know why please?
>
> Thank!
>
> --- Jon Wingfield <jo...@mkodo.com> schrieb:
>
>>try
>><%= rs.getString(i) %>
>>instead of
>><% = rs.getString(i) %>
>>
>>
>>Bruno Armand wrote:
>>
>>
>>>Please i try since one week to become this program
>>>without error, but without success. Perrhaps can
>>
>>you
>>
>>>help me!
>>>
>>>I write a jsp-file for calling and saving data
>>
>>from an
>>
>>>access existing database which i connect with a
>>>odbc-driver.
>>>The adrList.jsp ist in the directory
>>>c:\eclipse\workspace\projectX\
>>>I try to start it from tomcat with
>>>http://localhost:8080/student.
>>>The file HelloWorld.jsp in the same directory runs
>>>without problem.
>>>
>>>Please here are:
>>>1. The code of the adrList.jsp and
>>>2. The displayed errormessage.
>>>__________________________________-
>>>1.
>>><html>
>>><head>
>>><%@ page language="java" import = "java.sql.*" %>
>>><%@ page import = "java.lang.*" %>
>>><%
>>>try
>>>{
>>> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>
> String username = "";
> String password = "";
> String url = "jdbc:odbc:Bruno_Adress_odbc";
> Connection con = DriverManager.getConnection(url,
> username,password);
>
>
>>>String sql1 = "INSERT INTO Adressen (Nachname,
>>>Adresse," +
>>> " Postleitzahl, Land, Ort)" +
>>> " VALUES ('Bruno Armando', 'Am Vaihingen 20',
>>>'70187', " +
>>>"'Deutschland', 'Stuttgart')";
>>>
>>>String sql2 = "INSERT INTO Adressen (Nachname,
>>>Adresse,"+
>>> " Postleitzahl, Land, Ort) " +
>>> "VALUES ('Becker Marlise', 'Koenigstr 78',
>>
>>'70174',
>>
>>>"+
>>>"'Deutschland', 'Stuttgart')";
>>>
>>>String query = "SELECT * FROM Adressen";
>>>
>>>Statement stmt = con.createStatement();
>>>
>>>stmt.executeUpdate(sql1);
>>>stmt.executeUpdate(sql2);
>>>ResultSet rs = stmt.executeQuery(query);
>>>ResultSetMetaData rsmd = rs.getMetaData();
>>>int columnCount = rsmd.getColumnCount();
>>>%>
>>>
>>><title>Details-Adressen von den 5 Besten</title>
>>></head>
>>><BODY>
>>>
>>><TABLE width='80%' border=0 align='center'
>>>cellSpacing=5 cellPadding=2 bgcolor="#0000FF"
>>>bordercolor="#000000">
>>><tr>
>>><TD align=left> </TD>
>>> <TD align=right >
>>>
>>> </TD>
>>>
>>><td> Name</td>
>>><td> Street</td>
>>><td> Zip</td>
>>><td> Town</td>
>>><td> Country</td>
>>></tr>
>>>
>>><%
>>>while (rs.next())
>>>{
>>>%>
>>><tr>
>>> <TD align=left> </TD>
>>> <TD align=right > </TD>
>>><%
>>> for (int i = 2; i <= columnCount; i++)
>>>%>
>>> <td>
>>> <%= rs.getString(i) %>
>>> </td>
>>><%
>>>}
>>>%>
>>></tr><br>
>>><%
>>>}
>>>rs.close();
>>>stmt.close();
>>>con.close();
>>>}
>>>catch (SQLException ex)
>>>{
>>> System.out.println("SQLException:");
>>> while (ex != null)
>>> {
>>> System.out.println("SQLState: " +
>>>ex.getSQLState());
>>> System.out.println("Nachricht: " +
>>>ex.getMessage());
>>> System.out.println("Anbieter: " +
>>>ex.getErrorCode());
>>> ex = ex.getNextException();
>>> System.out.println("");
>>>}
>
> }
>
>>>%>
>>></table>
>>></body>
>>></html>
>>>
Re: jdbcodbc database connection problem (access-DB,jsp,tomcat,eclipse)!
Posted by Bruno Armand <na...@yahoo.de>.
Now,
i correct all the errors (As you see n the code
below), but the jsp-page ist displayed, but without
anything written (from html or database.). Can you
know why please?
Thank!
--- Jon Wingfield <jo...@mkodo.com> schrieb:
> try
> <%= rs.getString(i) %>
> instead of
> <% = rs.getString(i) %>
>
>
> Bruno Armand wrote:
>
> > Please i try since one week to become this program
> > without error, but without success. Perrhaps can
> you
> > help me!
> >
> > I write a jsp-file for calling and saving data
> from an
> > access existing database which i connect with a
> > odbc-driver.
> > The adrList.jsp ist in the directory
> > c:\eclipse\workspace\projectX\
> > I try to start it from tomcat with
> > http://localhost:8080/student.
> > The file HelloWorld.jsp in the same directory runs
> > without problem.
> >
> > Please here are:
> > 1. The code of the adrList.jsp and
> > 2. The displayed errormessage.
> > __________________________________-
> > 1.
> > <html>
> > <head>
> > <%@ page language="java" import = "java.sql.*" %>
> > <%@ page import = "java.lang.*" %>
> > <%
> > try
> > {
> > Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String username = "";
String password = "";
String url = "jdbc:odbc:Bruno_Adress_odbc";
Connection con = DriverManager.getConnection(url,
username,password);
> >
> > String sql1 = "INSERT INTO Adressen (Nachname,
> > Adresse," +
> > " Postleitzahl, Land, Ort)" +
> > " VALUES ('Bruno Armando', 'Am Vaihingen 20',
> > '70187', " +
> > "'Deutschland', 'Stuttgart')";
> >
> > String sql2 = "INSERT INTO Adressen (Nachname,
> > Adresse,"+
> > " Postleitzahl, Land, Ort) " +
> > "VALUES ('Becker Marlise', 'Koenigstr 78',
> '70174',
> > "+
> > "'Deutschland', 'Stuttgart')";
> >
> > String query = "SELECT * FROM Adressen";
> >
> > Statement stmt = con.createStatement();
> >
> > stmt.executeUpdate(sql1);
> > stmt.executeUpdate(sql2);
> > ResultSet rs = stmt.executeQuery(query);
> > ResultSetMetaData rsmd = rs.getMetaData();
> > int columnCount = rsmd.getColumnCount();
> > %>
> >
> > <title>Details-Adressen von den 5 Besten</title>
> > </head>
> > <BODY>
> >
> > <TABLE width='80%' border=0 align='center'
> > cellSpacing=5 cellPadding=2 bgcolor="#0000FF"
> > bordercolor="#000000">
> > <tr>
> > <TD align=left> </TD>
> > <TD align=right >
> >
> > </TD>
> >
> > <td> Name</td>
> > <td> Street</td>
> > <td> Zip</td>
> > <td> Town</td>
> > <td> Country</td>
> > </tr>
> >
> > <%
> > while (rs.next())
> > {
> > %>
> > <tr>
> > <TD align=left> </TD>
> > <TD align=right > </TD>
> > <%
> > for (int i = 2; i <= columnCount; i++)
> > %>
> > <td>
> > <%= rs.getString(i) %>
> > </td>
> > <%
> > }
> > %>
> > </tr><br>
> > <%
> > }
> > rs.close();
> > stmt.close();
> > con.close();
> > }
> > catch (SQLException ex)
> > {
> > System.out.println("SQLException:");
> > while (ex != null)
> > {
> > System.out.println("SQLState: " +
> > ex.getSQLState());
> > System.out.println("Nachricht: " +
> > ex.getMessage());
> > System.out.println("Anbieter: " +
> > ex.getErrorCode());
> > ex = ex.getNextException();
> > System.out.println("");
> > }
}
> > %>
> > </table>
> > </body>
> > </html>
> >
> > 2. Errormessage:
> >
> > HTTP Status 500 -
> >
> > type Exception report
> >
> > message
> >
> > description The server encountered an internal
> error
> > () that prevented it from fulfilling this request.
> >
> > exception
> >
> > org.apache.jasper.JasperException: Unable to
> compile
> > class for JSP
> >
> > An error occurred at line: 106 in the jsp file:
> > /adrList.jsp
> >
> > Generated servlet error:
> > [javac] Compiling 1 source file
> >
> > C:\Programme\Apache Group\Tomcat
> >
>
4.1\work\Standalone\localhost\student2\adrList_jsp.java:159:
> > illegal start of expression
> > = rs.getString(i)
> > ^
> >
> >
> >
> > An error occurred at line: 14 in the jsp file:
> > /adrList.jsp
> >
> > Generated servlet error:
> > C:\Programme\Apache Group\Tomcat
> >
>
4.1\work\Standalone\localhost\student2\adrList_jsp.java:58:
> > 'try' without 'catch' or 'finally'
> > try
> > ^
> >
> >
> >
> > An error occurred at line: 112 in the jsp file:
> > /adrList.jsp
> >
> > Generated servlet error:
> > C:\Programme\Apache Group\Tomcat
> >
>
4.1\work\Standalone\localhost\student2\adrList_jsp.java:186:
> > illegal start of expression
> > public static Connection getConnection()
> > ^
> >
> >
> >
> > An error occurred at line: 14 in the jsp file:
> > /adrList.jsp
> >
> > Generated servlet error:
> > C:\Programme\Apache Group\Tomcat
> >
>
4.1\work\Standalone\localhost\student2\adrList_jsp.java:61:
>
=== message truncated ===
__________________________________________________________________
Gesendet von Yahoo! Mail - http://mail.yahoo.de
Logos und Klingeltöne fürs Handy bei http://sms.yahoo.de
Re: jdbcodbc database connection problem (access-DB,jsp,tomcat,eclipse)!
Posted by Jon Wingfield <jo...@mkodo.com>.
try
<%= rs.getString(i) %>
instead of
<% = rs.getString(i) %>
Bruno Armand wrote:
> Please i try since one week to become this program
> without error, but without success. Perrhaps can you
> help me!
>
> I write a jsp-file for calling and saving data from an
> access existing database which i connect with a
> odbc-driver.
> The adrList.jsp ist in the directory
> c:\eclipse\workspace\projectX\
> I try to start it from tomcat with
> http://localhost:8080/student.
> The file HelloWorld.jsp in the same directory runs
> without problem.
>
> Please here are:
> 1. The code of the adrList.jsp and
> 2. The displayed errormessage.
> __________________________________-
> 1.
> <html>
> <head>
> <%@ page language="java" import = "java.sql.*" %>
> <%@ page import = "java.lang.*" %>
> <%
> try
> {
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> Properties props = new Properties();
> props.setProperty("user", "");
> props.setProperty("password", "");
> String url =
> "jdbc:odbc:http://localhost:8080:Bruno_Adress_odbc";
> Connection con = DriverManager.getConnection(url,
> props);
>
> String sql1 = "INSERT INTO Adressen (Nachname,
> Adresse," +
> " Postleitzahl, Land, Ort)" +
> " VALUES ('Bruno Armando', 'Am Vaihingen 20',
> '70187', " +
> "'Deutschland', 'Stuttgart')";
>
> String sql2 = "INSERT INTO Adressen (Nachname,
> Adresse,"+
> " Postleitzahl, Land, Ort) " +
> "VALUES ('Becker Marlise', 'Koenigstr 78', '70174',
> "+
> "'Deutschland', 'Stuttgart')";
>
> String query = "SELECT * FROM Adressen";
>
> Statement stmt = con.createStatement();
>
> stmt.executeUpdate(sql1);
> stmt.executeUpdate(sql2);
> ResultSet rs = stmt.executeQuery(query);
> ResultSetMetaData rsmd = rs.getMetaData();
> int columnCount = rsmd.getColumnCount();
> %>
>
> <title>Details-Adressen von den 5 Besten</title>
> </head>
> <BODY>
>
> <TABLE width='80%' border=0 align='center'
> cellSpacing=5 cellPadding=2 bgcolor="#0000FF"
> bordercolor="#000000">
> <tr>
> <TD align=left> </TD>
> <TD align=right >
>
> </TD>
>
> <td> Name</td>
> <td> Street</td>
> <td> Zip</td>
> <td> Town</td>
> <td> Country</td>
> </tr>
>
> <%
> while (rs.next())
> {
> %>
> <tr>
> <TD align=left> </TD>
> <TD align=right > </TD>
> <%
> for (int i = 2; i <= columnCount; i++)
> %>
> <td>
> <% = rs.getString(i) %>
> </td>
> <%
> }
> %>
> </tr><br>
> <%
> }
> rs.close();
> stmt.close();
> con.close();
> }
> catch (SQLException ex)
> {
> System.out.println("SQLException:");
> while (ex != null)
> {
> System.out.println("SQLState: " +
> ex.getSQLState());
> System.out.println("Nachricht: " +
> ex.getMessage());
> System.out.println("Anbieter: " +
> ex.getErrorCode());
> ex = ex.getNextException();
> System.out.println("");
> }
> %>
> </table>
> </body>
> </html>
>
> 2. Errormessage:
>
> HTTP Status 500 -
>
> type Exception report
>
> message
>
> description The server encountered an internal error
> () that prevented it from fulfilling this request.
>
> exception
>
> org.apache.jasper.JasperException: Unable to compile
> class for JSP
>
> An error occurred at line: 106 in the jsp file:
> /adrList.jsp
>
> Generated servlet error:
> [javac] Compiling 1 source file
>
> C:\Programme\Apache Group\Tomcat
> 4.1\work\Standalone\localhost\student2\adrList_jsp.java:159:
> illegal start of expression
> = rs.getString(i)
> ^
>
>
>
> An error occurred at line: 14 in the jsp file:
> /adrList.jsp
>
> Generated servlet error:
> C:\Programme\Apache Group\Tomcat
> 4.1\work\Standalone\localhost\student2\adrList_jsp.java:58:
> 'try' without 'catch' or 'finally'
> try
> ^
>
>
>
> An error occurred at line: 112 in the jsp file:
> /adrList.jsp
>
> Generated servlet error:
> C:\Programme\Apache Group\Tomcat
> 4.1\work\Standalone\localhost\student2\adrList_jsp.java:186:
> illegal start of expression
> public static Connection getConnection()
> ^
>
>
>
> An error occurred at line: 14 in the jsp file:
> /adrList.jsp
>
> Generated servlet error:
> C:\Programme\Apache Group\Tomcat
> 4.1\work\Standalone\localhost\student2\adrList_jsp.java:61:
> cannot resolve symbol
> symbol : method getConnection ()
> location: class org.apache.jsp.adrList_jsp
> Connection con = getConnection();
> ^
>
>
>
> An error occurred at line: 112 in the jsp file:
> /adrList.jsp
>
> Generated servlet error:
> C:\Programme\Apache Group\Tomcat
> 4.1\work\Standalone\localhost\student2\adrList_jsp.java:170:
> cannot resolve symbol
> symbol : variable rs
> location: class org.apache.jsp.adrList_jsp
> rs.close();
> ^
>
>
>
> An error occurred at line: 112 in the jsp file:
> /adrList.jsp
>
> Generated servlet error:
> C:\Programme\Apache Group\Tomcat
> 4.1\work\Standalone\localhost\student2\adrList_jsp.java:171:
> cannot resolve symbol
> symbol : variable stmt
> location: class org.apache.jsp.adrList_jsp
> stmt.close();
> ^
>
>
>
> An error occurred at line: 112 in the jsp file:
> /adrList.jsp
>
> Generated servlet error:
> C:\Programme\Apache Group\Tomcat
> 4.1\work\Standalone\localhost\student2\adrList_jsp.java:172:
> cannot resolve symbol
> symbol : variable con
> location: class org.apache.jsp.adrList_jsp
> con.close();
> ^
> 7 errors
>
>
> at
> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
> at
> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
> at
> org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
> at
> org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
> at
> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
> at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at
> org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
> at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
> at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
> at java.lang.Thread.run(Thread.java:536)
>
> ________________________
> Thank!
>
> Bruno!
>
>
> __________________________________________________________________
>
> Gesendet von Yahoo! Mail - http://mail.yahoo.de
> Logos und Klingeltöne fürs Handy bei http://sms.yahoo.de
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>