----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

Dear William,
 
Two things occur to me about this:
 
a) Do you register your driver in your code?
 
eg: to use a Sybase example:
 
     try {
              SybDriver sybdriver = (SybDriver) Class.forName
("com.sybase.jdbc2.jdbc.SybDriver").newInstance();

              sybdriver.setVersion (com.sybase.jdbcx.SybDriver.VERSION_5);
              DriverManager.registerDriver(sybdriver);
         }
         catch (Exception e)
         {
                        // do something useful with this exception
         }

b) System.out.println doesn't print to any logs that I can see. I use the
log() function instead from the ServletContext:
 
eg: inside your servlet 
 
        ServletContext context = getServletConfig().getServletContext();
   context.log("hello world");
 
this writes to the java log.
 
c) finally - and this is at the programming as magic end of things.
 
        There 'appear' to be some oddities of the interaction between the
Java virtual machine and JDBC. Have you tried putting the 
        
        Connection dbCon; 
 
        line AFTER the Class.forName();
        but BEFORE the getConnection();
 
 
Regards
Nick
        

-----Original Message-----
From: William Wong [mailto:[EMAIL PROTECTED]]
Sent: 09 February 2000 20:30
To: '[EMAIL PROTECTED]'
Subject: JDBC prob on JServ1.1



Dear all, 

Scenario: 
Win98, Apache 1.3.11, JServ 1.1, JSDK2.0, Oracle JDBC(thin client) 8.1.6 
Jserv is autoloaded by Apache. 
Oracle DB (8.0.5) is across network (TCP) on Solaris. 

Problem: 
Can't get any connections to work in servlet. 
Can't get any servlet messages in logs. 

Tried the following: 
In jserv.properties, added 
- wrapper.classpath=c:\java\linux-dist\jars\JDBCclasses12.zip 
In zone.properties, added 
- repositories=c:\java\linux-dist\jars\JDBCclasses12.zip 
In httpd.conf, 
LogLevel debug 

The servlet fails to connect somehow. No output was generated in Apache 
and 
JServ logs. Does not even logs System.err.println (purposely set this in 
init()). 
Browser only sees "hello" (based on program logic). 
Output of http://localhost/servlets/DBTest
<http://localhost/servlets/DBTest>  : 
hello 

A java application (with main()) works fine (after setting 
CLASSPATH=c:\java\linux-dist\jars\JDBCclasses12.zip;. in environment). 
Output of "java SimpleSQL": 
Result: LLTEST.WORLD 

As far as servlet execution, SessionSnoop and IsItWorking works fine. 

Tried the same set of programs on 
RHat6.1, BlackdownJDK1.2.2P4, Apache 1.3.9, JServ 1.1, JSDK2.0, Oracle 
JDBC(thin client) 8.1.6. 
Again, only the SimpleSQL app works. No mesgs in Apache & JServ logs. 

Thank you in advance for your assistance. 

-DBTest.java code----------------------------------------------- 
import javax.servlet.*; 
import javax.servlet.http.*; 

import java.io.*; 
import java.sql.*; 

public class DBTest extends HttpServlet { 

        Connection dbCon; 

        public void init() throws ServletException { 

                /* Connect to the database */ 
                try { 

                        Class.forName("oracle.jdbc.driver.OracleDriver"); 
                        dbCon =
DriverManager.getConnection("jdbc:oracle:thin:@bluesky:1521:lltest", 
                                "webtest","webtest"); 

                } catch (ClassNotFoundException e) { 

                        System.err.println("DBTest: Database Driver could
not be found."); 
                        System.err.println(e.toString()); 

                } catch (SQLException e) { 

                        System.err.println("DBTest: Error connecting to
database."); 
                        System.err.println(e.toString()); 
                } 
                System.err.println("End of Init"); 
                System.out.println("End of Init"); 
                ServletContext sc = getServletContext(); 
                sc.log("Init function"); 
        } 

        public void doGet(HttpServletRequest req, HttpServletResponse res) 
                        throws ServletException, IOException { 
        
                Statement stmt; 
                ResultSet rs; 

                res.setContentType("text/html"); 
                PrintWriter out = res.getWriter(); 

                /* Execute Query */ 

                try { 

                        if (dbCon != null) { 
                                stmt = dbCon.createStatement(); 
                                rs = stmt.executeQuery("select * from
global_name"); 
                                out.println("has value"); 
                        } 

                } 
                catch (SQLException e) { 
                        res.sendError(res.SC_ACCEPTED, "The request has been
accepted, but it failed to complete due to a problem querying the
database.");

                        return; 
                } 

                out.println("hello"); 

        } 

} 


********************************************************************
This e-mail is intended only for the addressee named above.
As this e-mail may contain confidential or privileged information,
if you are not the named addressee, you are not authorised to
retain, read, copy or disseminate this message or any part of it.
********************************************************************



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to