• RSS
  • Twitter
  • FaceBook

Security Forums

Log in

FAQ | Search | Usergroups | Profile | Register | RSS | Posting Guidelines | Recent Posts

JSP to Access Connection Using Tomcat?

Users browsing this topic:0 Security Fans, 0 Stealth Security Fans
Registered Security Fans: None
Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More

View previous topic :: View next topic  
Author Message
tkouan
Just Arrived
Just Arrived


Joined: 04 Dec 2002
Posts: 0
Location: Southern California, United States of America

Offline

PostPosted: Wed Dec 04, 2002 5:16 am    Post subject: JSP to Access Connection Using Tomcat? Reply with quote

I'm having a slight problem with connecting my JSP code, with out the use of servlets or beans, to an Access database. I am using Tomcat 4.1 Standalone on windows 2k Professional sp3. I have set up a DSN in windows odbc named "test". And have also Set up a JNDI through the tomcat gui interface named "test2"...both pointing to the same database. Although i am not sure if the tomcat one is using correct drivers..might be the problem...

Heres the Jsp code which i have refernced from a few books and websites

Code:


<html>
<body>
<%@ page language="java" import="java.io.*,java.sql.*,java.util.*, java.lang.*, javax.sql.*" %>
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); <!--// Complies this with out error //-->

<% String url = "jdbc:odbc:test"; %>

<% Connection con = DriverManager.getConnection(url); %> <!--//Attempt number 1 //-->
<br>
Connection dbCon=DriverManager.getConnection("jdbc:odbc:test"); <!--//Attempt number 2 //-->
<br>
Connection dbCon = DriverManager.getConnection("jdbc:odbc:[odbc test]");<!--//Attempt number 3 //-->
<%
String hi="Hellow World";
out.println(hi);
%>
</body>
</html>




Tomcat Settings
JNDI Name: test
DataSource URL: jdbc:odbc:[odbc test]
Driver: sun.jdbc.odbc.JdbcOdbcDriver



using any of those I get the error same errors. Now the I think its Tomcat that I am having difficulties with. Possibly the drivers for a access database..or somthing...not sure.

Any tips hints code would be helpfull
Back to top
View user's profile Send private message AIM Address MSN Messenger
ShaolinTiger
Forum Fanatic
Forum Fanatic


Joined: 18 Apr 2002
Posts: 16777215
Location: Kuala Lumpur, Malaysia

Offline

PostPosted: Wed Dec 04, 2002 11:56 am    Post subject: Reply with quote

Have you tried anything like this:

Connection dbconn;

dbconn = DriverManager.getConnection("jdbc:locationofdb.mdb","test","test");

Might it just be the fact you're not declaring con or dbCon?

I believe this is working code:

<%
Connection myConn;
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbUrl = "jdbc:odbc:MyDesResDSN";

Class.forName(driverName);
myConn = DriverManager.getConnection (dbUrl, user, pass);
Statement myStmt = myConn.createStatement();
ResultSet myRs = myStmt.executeQuery("SELECT * FROM tblName");
%>

There is a good tutorial on using JDBC here:

http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html
Back to top
View user's profile Send private message Visit poster's website
tkouan
Just Arrived
Just Arrived


Joined: 04 Dec 2002
Posts: 0
Location: Southern California, United States of America

Offline

PostPosted: Wed Dec 04, 2002 2:24 pm    Post subject: progress maby? Reply with quote

I get a new error atleast

Quote:

org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Apoc\testforum_jsp.java:43: cannot resolve symbol
symbol : class Connection
location: class org.apache.jsp.testforum_jsp
Connection myConn;
^

An error occurred at line: 1 in the jsp file: /Apoc/testforum.jsp

Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Apoc\testforum_jsp.java:51: cannot resolve symbol
symbol : variable DriverManager
location: class org.apache.jsp.testforum_jsp
myConn = DriverManager.getConnection (dbUrl, user, pass);
^



An error occurred at line: 1 in the jsp file: /Apoc/testforum.jsp

Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Apoc\testforum_jsp.java:52: cannot resolve symbol
symbol : class Statement
location: class org.apache.jsp.testforum_jsp
Statement myStmt = myConn.createStatement();
^



An error occurred at line: 13 in the jsp file: /Apoc/testforum.jsp

Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Apoc\testforum_jsp.java:53: cannot resolve symbol
symbol : class ResultSet
location: class org.apache.jsp.testforum_jsp
ResultSet myRs = myStmt.executeQuery("SELECT * FROM tblName");
^
4 errors


at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:120)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:313)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:324)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
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:260)
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:2396)
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:170)
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:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Unknown Source)


sorry for posting all of that....

but thats the entire error with the code of
Code:

<html>
<%
Connection myConn;
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbUrl = "jdbc:odbc:test";
String user;
String pass;


Class.forName(driverName);
myConn = DriverManager.getConnection (dbUrl, user, pass);
Statement myStmt = myConn.createStatement();
ResultSet myRs = myStmt.executeQuery("SELECT * FROM tblName");
%>
</html>


I will continue to play with this
thanks for your help

more suggestions are welcome
Back to top
View user's profile Send private message AIM Address MSN Messenger
browolf
Trusted SF Member
Trusted SF Member


Joined: 19 Apr 2002
Posts: 1


Offline

PostPosted: Wed Dec 04, 2002 6:42 pm    Post subject: Reply with quote

your 4 errors are all "cannot resolve symbol"
and they are all indicated at the start of a line

it might be something fundamental you are doing wrong.

I suggest reading all the messages in google groups for "cannot resolve symbol" until you find one that has a explanation that might apply to your case.

what i know about jsp and tomcat could be written on the ripped off corner of a postage stamp but I can tell you how i find solutions when i have problem programming.
Back to top
View user's profile Send private message
Display posts from previous:   

Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More All times are GMT + 2 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Community Area

Log in | Register