Link to home
Start Free TrialLog in
Avatar of jinghuei
jinghueiFlag for Taiwan, Province of China

asked on

newbie question: Jbuilder2006 database connect ok, but jsp file cannot create connection

I am learning how to use Jbuilder2006 to develop a webapp.

Before I get to Jbuilder2006, I use a jsp file for Tomcat5.5 , JDK1.5 and MS sqlserver2000 to test an JNDI connection.
It works fine.

When I create a jubilder project for it, got an error msg:---cannot create JDBC driver for class  " " to URL null.

I had have seen data of my database use DATABASE PILOT,
 and add the 3 jar files of sqlserver as requried library in Project Property.
------- The ms sqlserver driver should have loaded correctly.

The server.xml file under %Jbuilder_JAVA_Home%/conf  and the web.xml file are set as before.

and the jsp file is as:
----------------------------------------------------------------
<%@ page contentType="text/html; charset=Big5"
      import="java.sql.*, javax.sql.*, javax.naming.*"%>
<HTML>
<HEAD>
<TITLE>Get data with JNDI connection</TITLE>
</HEAD>
<BODY>
<CENTER>
<FONT SIZE = 5 COLOR = blue>Get data with JNDI connection</FONT>
</CENTER>
<HR>
<P></P>

<CENTER>
<%
try{
System.out.println("1---------------------------");
String dbName = "java:comp/env/jdbc/ACCM";
System.out.println("2-------------------");
InitialContext ic = new InitialContext();
System.out.println("3---------------------------");
DataSource ds = (DataSource) ic.lookup(dbName);
System.out.println("4---------------------------");
Connection con = ds.getConnection();
System.out.println("5---------------------------");
Statement stmt = con.createStatement();

ResultSet rs;

rs = stmt.executeQuery("SELECT * FROM dept");

%>
<TABLE  bgcolor=DodgerBlue>
      <TR  bgcolor=SkyBlue>
      <TD><B>userid</B></TD><TD><B>pwd</B></TD><TD><B>clevel/B></TD>
      </TR>
      <%
      
      while (rs.next())
      {
            %>
            <TR bgcolor=LightGoldenrodYellow>
            <TD><B><%= rs.getString("userid") %></B></TD>
            <TD><B><%= rs.getString("pwd") %></B></TD>
            <TD><B><%= rs.getString("clevel") %></B></TD>
            </TR>
            <%
      }

      
      if(rs != null) rs.close();
      if(stmt != null) stmt.close();
      if(con != null) con.close();

} catch(Exception ex) {
System.out.println(ex.toString());
}
      %>
</TABLE>
</CENTER>

</BODY>
</HTML>

------------------------------------------------------------------------------------------------

The message of the execution "http://localhost:8080/JNDI.jsp" showed  under Tomcat as following:
//**-------------------------------------------------------------------------------------------------

1---------------------------
2---------------------------
3---------------------------
4---------------------------

org.apache.tomcat.dbcp.dbcp.SQLNestedException:Cannot create JDBC driverof class '' for connect URL 'null'.
------------------------------------------------------------------------------------------------*/
That meant it cannot get to '5'--the connection.

Is there other setting should be done?


I need help.

Thanks,experts


Catherine

Avatar of bloodredsun
bloodredsun
Flag of Australia image

>>:Cannot create JDBC driverof class '' for connect URL 'null'.

This indicates that the specified driver cannot be found on the classpath. Check the availability of the driver and the database url and driver name
Avatar of jinghuei

ASKER

Hi,bloodred sun:
Thank you for responding.

The url I put in Datapilot is --    jdbc:microsoft.sqlserver://localhost:1433  
(**just as same as in the server.xml but without the databasename and the password)
and the driver I put in Data pilot is -- com.microsoft.jdbc.sqlserver.SQLServerDriver  
(**just as same as in the server.xml ).


I don't understand.
Since I can retrieve table data of database using Data pilot,
could there still be the problem?

Catherine
I check my CLASS_PATH that includes the 3 jar files but in the sqlserver driver installed directory.
The path of 3 classes inside  the new library created in "My Tools\Configure Libraries" was different.

The old path is set to "%Jbuilder_Home/thirdparty\jakarta-tomcat-5.5.9\common\lib" , there is a copy of these 3 files.
Now I change the libray files to  the path to the sqlserver driver installed directory ,
 so the specifed drivers are put in the CLASS_PATH.

Then I restart Jbuilder, and run the jsp file.

The error msg -- "Cannot create JDBC driverof class '' for connect URL 'null' is gone.
There is a blank web -- nothing comes out at all with no error msg.
The web even don't have " title" part come out.

I wonder where I can check the log and fix it?
There is no log under "%Jbuilder_Home/thirdparty\jakarta-tomcat-5.5.9\log" at all.

Thank for help in advance>

catherine






When I run the program and get blank web.
The message box of the Tomcat shows as below:
------------------------------------------------------------



C:\JBuilder2006\jdk1.5\bin\javaw -classpath "C:\JBuilder2006\thirdparty\jakarta-tomcat-5.5.9\bin\bootstrap.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;C:\JBuilder2006\jdk1.5\lib\tools.jar"  "-Dcatalina.home=C:/JBuilder2006/thirdparty/jakarta-tomcat-5.5.9"  org.apache.catalina.startup.Bootstrap -config D:\jbproject\testDB\Tomcat\conf\server8080.xml start
2006/2/13 Afternoon 07:07:03 org.apache.coyote.http11.Http11Protocol init
Message: Initializing Coyote HTTP/1.1 on http-8080
2006/2/13 Afternoon 07:07:03 org.apache.catalina.startup.Catalina load
Message: Initialization processed in 1125 ms
2006/2/13 Afternoon 07:07:03 org.apache.catalina.core.StandardService start
Message: Starting service Catalina
2006/2/13 Afternoon 07:07:03 org.apache.catalina.core.StandardEngine start
Message: Starting Servlet Engine: Apache Tomcat/5.5.9
2006/2/13 Afternoon 07:07:03 org.apache.catalina.core.StandardHost start
Message: XML validation disabled
2006/2/13 Afternoon 07:07:04 org.apache.catalina.realm.JAASRealm setContainer
Message: Set JAAS app name Catalina
2006/2/13 Afternoon 07:07:05 org.apache.coyote.http11.Http11Protocol start
Message: Starting Coyote HTTP/1.1 on http-8080
2006/2/13 Afternoon 07:07:05 org.apache.catalina.startup.Catalina start
Message: Server startup in 2047 ms

-------------------------------------------------------------------------------------------------
Does it help to trace why the blank web comes out?


Urge to have your help!

Thank you.

Catherine
Hi, bloodredsun:
**This indicates that the specified driver cannot be found on the classpath. Check the availability of the driver and the database url and driver name
-----------------------------------------------------------------------------------------------------------------------

What should the CLASS_PATH contain for JBUILDER with JDBC for sqlserver?
Does CLASS_PATH contains

C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;

is enough for Jbuilder?

Catherine

I reinstall my Jbuilder2006 and redo some configurations and open the log.
Now I have the message of Tomcat becomes:

1---------------------------
2--------------------------
3---------------------------
4---------------------------
DriverManager.getDriver("null")
DriverManager.initialize: jdbc.drivers = null
JDBC DriverManager initialized
getDriver: no suitable driver
java.sql.SQLException: No suitable driver
      at java.sql.DriverManager.getDriver(DriverManager.java:243)
      at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
      at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
      at org.apache.jsp.sqlcon_jsp._jspService(org.apache.jsp.sqlcon_jsp:68)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)
SQLException: SQLState(08001)
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
---------------------------------------------------------------------------------------------------------------------------------


I don't know why it gets the lines:
-----------------------------------------------------------
DriverManager.getDriver("null")
DriverManager.initialize: jdbc.drivers = null
JDBC DriverManager initialized
getDriver: no suitable driver

----------------------------------------------------------

How to fix the problem?
(I can retrieve data from database pilot, and sure to put the sqldriver files in my CLASS_PATH.)


Any help will be very much appreciated.

Catherine



Problem solved!

It's wrong for me to change the server.xml under the "%Jbuilder_Home/thirdparty\jakarta-tomcat-5.5.9\conf".

I should modify the server8080.xml under %myproject%/Tomcat/conf.

I wonder the help on-line book of Jbuuilder says it.

Too happy to have it solved!

Anyway! Thank everybody!

Catherine
ASKER CERTIFIED SOLUTION
Avatar of DarthMod
DarthMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial