Serious problem of jdbc-mysql connectivity using tomcat

hi everybody
i m in serious problem since last 15-20 days. i m trying hard to make the connection jdbc-mysql using tomcat with the help of a jsp test page but every time i am facing almost the similar probems listed below in detail:
to make sure that the jdrivers's .jar (mysql-connector-java-3.1.7-bin.jar) available for such connections working fine i have tried the above said connection without using tomcat....which is working fine...for this i have created a dummy database with a dummy table ..and written some queries in the .java file of my code which upon running inserts the specified values in the defined(dummy) database.
this is the confirmation that the classpath etc..are ok in regard to the mysql-connector-java-3.1.7-bin.jar
now i have placed a copy of this .jar file in to the commons/lib directory of the tomcat web server(which is suppossed to be the place for such external jars)
after doing so i have followed 2 methods :
method 1st:........
i have made aone more jar file from the following .java file....
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
public class TestSQLLoad
String user = "Not Connected";
String pwd = "no pwd";
int id = -1;
public void init() {
try{
Context ctx = new InitialContext();
if(ctx == null ) {
throw new Exception("Boom - No Context");
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
if (ds != null) {
Connection conn = ds.getConnection();
if(conn != null) {
user = "Got Connection "+conn.toString();
Statement stmt = conn.createStatement();
String q = "select name, password, id from user";
ResultSet rst = stmt.executeQuery(q);
if(rst.next()) {
user=rst.getString(1);
pwd=rst.getString(2);
id = rst.getInt(3);
conn.close();
}catch(Exception e) {
e.printStackTrace();
public String getUser() {
return user;
public String getPassword() {
return pwd;
public int getID()
return id;
after compiling it at the cmd prompt i made a .jar file from the .class of it and named it MySQLLoad.jar...then i placed it also in to the commons/lib directory where the mysql-connector-java-3.1.7-bin.jar was already placed.
then i have changed the server.xml and web.xml files from the conf directory of the tomcat as given here:
server.xml
<!-- Example Server Configuration File -->
<!-- Note that component elements are nested corresponding to their
parent-child relationships with each other -->
<!-- A "Server" is a singleton element that represents the entire JVM,
which may contain one or more "Service" instances. The Server
listens for a shutdown command on the indicated port.
Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<Server port="8005" shutdown="SHUTDOWN">
<!-- Comment these entries out to disable JMX MBeans support used for the
administration web application -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" (and therefore the web applications visible
within that Container). Normally, that Container is an "Engine",
but this is not required.
Note: A "Service" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Catalina">
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector
port="80" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<!-- Note : To disable connection timeouts, set connectionTimeout value
to 0 -->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/testdb" docBase="TOMCAT_HOME/webapps/tomcat-docs/testdb"
debug="5" reloadable="true" crossContext="true" >
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>5</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>mysql</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/testdb?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
</Host>
</Engine>
</Service>
</Server>
and the other xml file i.e
web.xml is here:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>default</servlet-name>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-cl ***>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
<!-- The mapping for the JSP servlet -->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<mime-mapping>
<extension>abs</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ai</extension>
<mime-type>application/postscript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>aif</extension>
<mime-type>audio/x-aiff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>aifc</extension>
<mime-type>audio/x-aiff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>aiff</extension>
<mime-type>audio/x-aiff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>aim</extension>
<mime-type>application/x-aim</mime-type>
</mime-mapping>
<mime-mapping>
<extension>art</extension>
<mime-type>image/x-jg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>asf</extension>
<mime-type>video/x-ms-asf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>asx</extension>
<mime-type>video/x-ms-asf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>au</extension>
<mime-type>audio/basic</mime-type>
</mime-mapping>
<mime-mapping>
<extension>avi</extension>
<mime-type>video/x-msvideo</mime-type>
</mime-mapping>
<mime-mapping>
<extension>avx</extension>
<mime-type>video/x-rad-screenplay</mime-type>
</mime-mapping>
<mime-mapping>
<extension>bcpio</extension>
<mime-type>application/x-bcpio</mime-type>
</mime-mapping>
<mime-mapping>
<extension>bin</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>bmp</extension>
<mime-type>image/bmp</mime-type>
</mime-mapping>
<mime-mapping>
<extension>body</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>cdf</extension>
<mime-type>application/x-cdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>cer</extension>
<mime-type>application/x-x509-ca-cert</mime-type>
</mime-mapping>
<mime-mapping>
<extension>class</extension>
<mime-type>application/java</mime-type>
</mime-mapping>
<mime-mapping>
<extension>cpio</extension>
<mime-type>application/x-cpio</mime-type>
</mime-mapping>
<mime-mapping>
<extension>csh</extension>
<mime-type>application/x-csh</mime-type>
</mime-mapping>
<mime-mapping>
<extension>css</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
<extension>dib</extension>
<mime-type>image/bmp</mime-type>
</mime-mapping>
<mime-mapping>
<extension>doc</extension>
<mime-type>application/msword</mime-type>
</mime-mapping>
<mime-mapping>
<extension>dtd</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>dv</extension>
<mime-type>video/x-dv</mime-type>
</mime-mapping>
<mime-mapping>
<extension>dvi</extension>
<mime-type>application/x-dvi</mime-type>
</mime-mapping>
<mime-mapping>
<extension>eps</extension>
<mime-type>application/postscript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>etx</extension>
<mime-type>text/x-setext</mime-type>
</mime-mapping>
<mime-mapping>
<extension>exe</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gif</extension>
<mime-type>image/gif</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gtar</extension>
<mime-type>application/x-gtar</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gz</extension>
<mime-type>application/x-gzip</mime-type>
</mime-mapping>
<mime-mapping>
<extension>hdf</extension>
<mime-type>application/x-hdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>hqx</extension>
<mime-type>application/mac-binhex40</mime-type>
</mime-mapping>
<mime-mapping>
<extension>htc</extension>
<mime-type>text/x-component</mime-type>
</mime-mapping>
<mime-mapping>
<extension>htm</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>hqx</extension>
<mime-type>application/mac-binhex40</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ief</extension>
<mime-type>image/ief</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jad</extension>
<mime-type>text/vnd.sun.j2me.app-descriptor</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jar</extension>
<mime-type>application/java-archive</mime-type>
</mime-mapping>
<mime-mapping>
<extension>java</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jnlp</extension>
<mime-type>application/x-java-jnlp-file</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jpe</extension>
<mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jpeg</extension>
<mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jpg</extension>
<mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>text/javascript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jsf</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jspf</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>kar</extension>
<mime-type>audio/x-midi</mime-type>
</mime-mapping>
<mime-mapping>
<extension>latex</extension>
<mime-type>application/x-latex</mime-type>
</mime-mapping>
<mime-mapping>
<extension>m3u</extension>
<mime-type>audio/x-mpegurl</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mac</extension>
<mime-type>image/x-macpaint</mime-type>
</mime-mapping>
<mime-mapping>
<extension>man</extension>
<mime-type>application/x-troff-man</mime-type>
</mime-mapping>
<mime-mapping>
<extension>me</extension>
<mime-type>application/x-troff-me</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mid</extension>
<mime-type>audio/x-midi</mime-type>
</mime-mapping>
<mime-mapping>
<extension>midi</extension>
<mime-type>audio/x-midi</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mif</extension>
<mime-type>application/x-mif</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mov</extension>
<mime-type>video/quicktime</mime-type>
</mime-mapping>
<mime-mapping>
<extension>movie</extension>
<mime-type>video/x-sgi-movie</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mp1</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mp2</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mp3</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpa</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpe</extension>
<mime-type>video/mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpeg</extension>
<mime-type>video/mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpega</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpg</extension>
<mime-type>video/mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpv2</extension>
<mime-type>video/mpeg2</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ms</extension>
<mime-type>application/x-wais-source</mime-type>
</mime-mapping>
<mime-mapping>
<extension>nc</extension>
<mime-type>application/x-netcdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>oda</extension>
<mime-type>application/oda</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pbm</extension>
<mime-type>image/x-portable-bitmap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pct</extension>
<mime-type>image/pict</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pdf</extension>
<mime-type>application/pdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pgm</extension>
<mime-type>image/x-portable-graymap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pic</extension>
<mime-type>image/pict</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pict</extension>
<mime-type>image/pict</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pls</extension>
<mime-type>audio/x-scpls</mime-type>
</mime-mapping>
<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pnm</extension>
<mime-type>image/x-portable-anymap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pnt</extension>
<mime-type>image/x-macpaint</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ppm</extension>
<mime-type>image/x-portable-pixmap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ppt</extension>
<mime-type>application/powerpoint</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ps</extension>
<mime-type>application/postscript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>psd</extension>
<mime-type>image/x-photoshop</mime-type>
</mime-mapping>
<mime-mapping>
<extension>qt</extension>
<mime-type>video/quicktime</mime-type>
</mime-mapping>
<mime-mapping>
<extension>qti</extension>
<mime-type>image/x-quicktime</mime-type>
</mime-mapping>
<mime-mapping>
<extension>qtif</extension>
<mime-type>image/x-quicktime</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ras</extension>
<mime-type>image/x-cmu-raster</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rgb</extension>
<mime-type>image/x-rgb</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rm</extension>
<mime-type>application/vnd.rn-realmedia</mime-type>
</mime-mapping>
<mime-mapping>
<extension>roff</extension>
<mime-type>application/x-troff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rtf</extension>
<mime-type>application/rtf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rtx</extension>
<mime-type>text/richtext</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sh</extension>
<mime-type>application/x-sh</mime-type>
</mime-mapping>
<mime-mapping>
<extension>shar</extension>
<mime-type>application/x-shar</mime-type>
</mime-mapping>
<mime-mapping>
<extension>smf</extension>
<mime-type>audio/x-midi</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sit</extension>
<mime-type>application/x-stuffit</mime-type>
</mime-mapping>
<mime-mapping>
<extension>snd</extension>
<mime-type>audio/basic</mime-type>
</mime-mapping>
<mime-mapping>
<extension>src</extension>
<mime-type>application/x-wais-source</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sv4cpio</extension>
<mime-type>application/x-sv4cpio</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sv4crc</extension>
<mime-type>application/x-sv4crc</mime-type>
</mime-mapping>
<mime-mapping>
<extension>swf</extension>
<mime-type>application/x-shockwave-flash</mime-type>
</mime-mapping>
<mime-mapping>
<extension>t</extension>
<mime-type>application/x-troff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tar</extension>
<mime-type>application/x-tar</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tcl</extension>
<mime-type>application/x-tcl</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tex</extension>
<mime-type>application/x-tex</mime-type>
</mime-mapping>
<mime-mapping>
<extension>texi</extension>
<mime-type>application/x-texinfo</mime-type>
</mime-mapping>
<mime-mapping>
<extension>texinfo</extension>
<mime-type>application/x-texinfo</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tif</extension>
<mime-type>image/tiff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tiff</extension>
<mime-type>image/tiff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tr</extension>
<mime-type>application/x-troff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tsv</extension>
<mime-type>text/tab-separated-values</mime-type>
</mime-mapping>
<mime-mapping>
<extension>txt</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ulw</extension>
<mime-type>audio/basic</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ustar</extension>
<mime-type>application/x-ustar</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xbm</extension>
<mime-type>image/x-xbitmap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xht</extension>
<mime-type>application/xhtml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xhtml</extension>
<mime-type>application/xhtml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xml</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xpm</extension>
<mime-type>image/x-xpixmap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xwd</extension>
<mime-type>image/x-xwindowdump</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wav</extension>
<mime-type>audio/x-wav</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svg</extension>
<mime-type>image/svg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svgz</extension>
<mime-type>image/svg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>vsd</extension>
<mime-type>application/x-visio</mime-type>
</mime-mapping>
<mime-mapping>
<!-- Wireless Bitmap -->
<extension>wbmp</extension>
<mime-type>image/vnd.wap.wbmp</mime-type>
</mime-mapping>
<mime-mapping>
<!-- WML Source -->
<extension>wml</extension>
<mime-type>text/vnd.wap.wml</mime-type>
</mime-mapping>
<mime-mapping>
<!-- Compiled WML -->
<extension>wmlc</extension>
<mime-type>application/vnd.wap.wmlc</mime-type>
</mime-mapping>
<mime-mapping>
<!-- WML Script Source -->
<extension>wmls</extension>
<mime-type>text/vnd.wap.wmlscript</mime-type>
</mime-mapping>
<mime-mapping>
<!-- Compiled WML Script -->
<extension>wmlscriptc</extension>
<mime-type>application/vnd.wap.wmlscriptc</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wrl</extension>
<mime-type>x-world/x-vrml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>Z</extension>
<mime-type>application/x-compress</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z</extension>
<mime-type>application/x-compress</mime-type>
</mime-mapping>
<mime-mapping>
<extension>zip</extension>
<mime-type>application/zip</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
after all this i have taken a jsp page whose code is here:
(the mysql database used is named as "testdb" and the table name is "user" which is having fields name,password and id)
<html>
<head>
<title>DB Test</title>
</head>
<body>
<%
TestSQLLoad tst = new TestSQLLoad ( );
tst.init();
%>
<h2>Results</h2>
User <%= tst.getUser() %>
Pwd <%= tst.getPassword() %>
Id <%= tst.getID() %>
</body>
</html>
and placed it in to the Tomcat 5.5\webapps\tomcat-docs\testdb directory and saved as test-db.jsp
when i run this page on the browser i get a lot may errors stating
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.j ava:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.4 logs.
AND NOW WHEN just to get rid of such errords i try to include a statement
<%@ page import="pkg.TestSQLLoad" %> in the jsp page code (and also place the MySQLLoad.class file in a folder called pkg and place it in the same directory where the jsp page is )and make it look like
<html>
<head>
<%@ page import="pkg.TestSQLLoad" %>
<title>DB Test</title>
</head>
<body>
<%
TestSQLLoad tst = new TestSQLLoad ( );
tst.init();
%>
<h2>Results</h2>
User <%= tst.getUser() %>
Pwd <%= tst.getPassword() %>
Id <%= tst.getID() %>
</body>
</html>
now when i run it i get the following errors:
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
Only a type can be imported. pkg.TestSQLLoad resolves to a package
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.j ava:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
in response to the above error i have even tried placing the MySQLLoad.class directly in the testdb folder along with the jsp page without keeping it in a package named pkg and then importing directly as <@page import="MySQLLoad" %>
that too gave me the following errors
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
The import TestSQLLoad cannot be resolved
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.j ava:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
and if i do not use the statement <%@ page import="MySQLLoad"%> then also i get the errors like
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 11 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
An error occurred at line: 11 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.j ava:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
THE 2nd Method:
in my second method i did the same changes in the web.xml and server.xml
then i took a jsp page with the following code:
<%@ page import="javax.sql.*,java.sql.*,javax.naming.*,com.mysql.jdbc.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> trial doc </TITLE>
</HEAD>
<BODY>
<h1>Trial Document</h1>
<% InitialContext context=new InitialContext( );
DataSource dataSource=(DataSource) context.lookup("java:comp/env/jdbc/testdb");
Connection conn=dataSource.getConnection();
Statement stmt=conn.createStatement();
ResultSet rset=stmt.executeQuery("select * from user");
if (rset.next()){
%>
<table width="100%" border="1">
<tr align="left">
<th>name</th> <th>password</th><th>id</th>
</tr>
<%
do {
%>
<tr><td> <%=rset.getString(1)%> </td>
<td><%=rset.getString(2) %></td>
<td><%=rset.getString(3) %></td></tr>
<%
} while (rset.next());
%>
</table>
<%
} else{
%>
No results from query
<%
rset.close();
stmt.close();
conn.close();
context.close();
%>
</BODY>
</HTML>
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 15 in the jsp file: /testdb/Big1.jsp
Generated servlet error:
The type Connection is ambiguous
An error occurred at line: 15 in the jsp file: /testdb/Big1.jsp
Generated servlet error:
The type Statement is ambiguous
An error occurred at line: 15 in the jsp file: /testdb/Big1.jsp
Generated servlet error:
The type ResultSet is ambiguous
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.j ava:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(C

thanx for ur response
as u said that the problem is more of a jsp page not getting compiled....
me also pointed towards the similar situation providing all the surrounding situations
which i have met and gone through
i m still thinking that problem may b in the tomcat's server.xml and web.xml as well
so better if u plz guide me in that regard
regards,
kuldeep

Similar Messages

  • A very surprise problem about JDBC and connection pool

    I occur a very problem about JDBC and connection pool on Weblogic Platform
    8.1.
    There is a table in Oracle
    Table
    Name: t1
    id varchar2(5);
    content clob;
    id is primary key.
    If I use a connection pool to connect to Oracle,like following program:
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup("cgOracleDataSource");
    con = ds.getConnection();
    then following program will throw a ClassCastException
    String sql = "select content from t1 where id = ?";
    PreparedStatement pst = con.prepareStatement(sql);
    pst.setString(1,"001");
    oracle.sql.CLOB clob = (oralce.sql.CLOB)rs.getClob("content") //this
    statement will throw ClassCastException
    but if I use JNDI to connect to Oracle,like following program, then those
    program above is ok
    private String dbdriver="oracle.jdbc.driver.OracleDriver";
    private String dburl="jdbc:oracle:thin:@192.168.7.148:1521:ep";
    private String username="ep";
    private String password="epuser";
    Class.forName(dbdriver);
    conn = DriverManager.getConnection(dburl, username, password);
    conn.setAutoCommit(false);
    On the contrary, if I use JNDI to connect to Oracle, following program will
    throw ClassCastException
    weblogic.jdbc.vendor.oracle.OracleThinClob clob =
    (weblogic.jdbc.vendor.oracle.OracleThinClob)rs.getClob("content");
    but it is fine if I use connection pool to connect to Oracle.
    I am confused this problem, who can tell me why?
    Daniel

    When you are getting connection using datasource lookup from weblogic
    connection pool, this connection is internally wrapped and hence you have to
    cast it to weblogic.jdbc.vendor.oracle.OracleThinClob which you do and so it
    works.
    But when you get connection by loading driver straight, you are getting naked
    oracle connection. In this case when you cast it to oracle.sql.Clob it works,
    as you have seen in your test case.
    I hope this explains what is going on with your code.
    Thanks,
    Mitesh
    Daniel wrote:
    I occur a very problem about JDBC and connection pool on Weblogic Platform
    8.1.
    There is a table in Oracle
    Table
    Name: t1
    id varchar2(5);
    content clob;
    id is primary key.
    If I use a connection pool to connect to Oracle,like following program:
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup("cgOracleDataSource");
    con = ds.getConnection();
    then following program will throw a ClassCastException
    String sql = "select content from t1 where id = ?";
    PreparedStatement pst = con.prepareStatement(sql);
    pst.setString(1,"001");
    oracle.sql.CLOB clob = (oralce.sql.CLOB)rs.getClob("content") //this
    statement will throw ClassCastException
    but if I use JNDI to connect to Oracle,like following program, then those
    program above is ok
    private String dbdriver="oracle.jdbc.driver.OracleDriver";
    private String dburl="jdbc:oracle:thin:@192.168.7.148:1521:ep";
    private String username="ep";
    private String password="epuser";
    Class.forName(dbdriver);
    conn = DriverManager.getConnection(dburl, username, password);
    conn.setAutoCommit(false);
    On the contrary, if I use JNDI to connect to Oracle, following program will
    throw ClassCastException
    weblogic.jdbc.vendor.oracle.OracleThinClob clob =
    (weblogic.jdbc.vendor.oracle.OracleThinClob)rs.getClob("content");
    but it is fine if I use connection pool to connect to Oracle.
    I am confused this problem, who can tell me why?
    Daniel

  • Getting an error in JDBC mySQL Connection

    Hi,
    I am creating JDBC mySQL Connection error.
    The eror messsage is
    Incorrect name parameter jdbc:mysql://10.114.16.70:3306/kaushikb root,pass in naming operation.where root is the username and pass is the password and kaushikb is the database name.
    I am entering the tablename as: emptable.
    Regards
    Taton
    Edited by: Taton on Dec 11, 2008 3:15 PM

    Let me guess: you did
    getConnection("jdbc:mysql://10.114.16.70:3306/kaushikb root,pass");rather than
    getConnection("jdbc:mysql://10.114.16.70:3306/kaushikb", "root", "pass");

  • Problem in Server side includes using Tomcat

    Problem in Server side includes using Tomcat:
    I am trying out small programs in servlet.
    I get one example program for server side includes from net.
    The code is:
    <HTML>
    <HEAD><TITLE>Times!</TITLE></HEAD>
    <BODY>
    <P>
    The current time in London is!!! :
    <SERVLET CODE="CurrentTime" codebase="../servlet">
    <PARAM NAME="zone" VALUE="GMT">
    </SERVLET>
    </P>
    </BODY>
    </HTML>
    I placed this test.shtml file in tomcat-home/webapps/ROOT folder and i kept the servlet in WEB-INF/classes folder.
    I renamed the servlets-ssi.jar and i removed the comments for SSI in web.xml file.
    When i run the servlet separately, i am getting the correct result. But if i run shtml file with the URL : http://localhost:8080/Test.shtml,
    i am getting the result as:
    The current time in London is!!! :
    It is not invoking servlet program.
    CAN ANYONE HELP ON THIS!
    Thanks.

    Thanks...as u said I tried putting dir & found that
    my file was saved as Ch1Servlet.java.txt instead for
    Ch1Servlet.java......So that was a problem.Now I'm
    able to compile.Oh, yeah. Notepad will do that to you. I think when you save in Notepad if you put quotes around the name "Whatever.java" then it won't add the .txt.
    But on compiling I'm getting the following error
    package java.servlet.* does not exist
    package java.servlet.http.* does not exist
    package java.io.* does not exist
    Do u the reason for this??? The servlet stuff is java[b]x.servlet. For the io stuff, I don't know, I'd have to see your code. Either you have a typo or a corrupt installation.

  • Both xp and windows 7 have video problems with my VGA connection using TV

    both xp and windows 7 have video problems with my VGA connection using TV as my monitor when it gets to starting up windows no matter what version it will not I have let my mac on all night and still says starting windows or the windows 7 logo and nothing else will happen also when I use a 3rd patty software like peraills or other it works like a charm how to fix it?

    To map the drive on your computer click on Start - RUN - type "\\192.168.1.1" and click ok... When prompted for Username and Password type "admin" and click ok... Now you will be able to see the folder which you have shared on  your router, right click on it and select "Map network drive" and click on finish.
    Now it will map the drive on your computer and you should be able to transfer the file from your computer to the USB drive.

  • MySQL connection pooling (tomcat) problem

    Hi all i just started learning servlets and i want to make a program in order to understand database connection pooling in tomcat.My problem is that when i run the servlet i created i get this error :
    java.lang.NullPointerException org.DB.TestDB2.doGet(TestDB2.java:105) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    And that from tomcat log from netbeans :
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' 
    .I configured tomcat server.xml file like this :
    <Context path="/DBTest" docBase="DBTest"         debug="5" reloadable="true" crossContext="true">   <Resource name="jdbc/phonebook_db" auth="Container" type="javax.sql.DataSource"               maxActive="100" maxIdle="30" maxWait="10000"               username="*******" password="********" removeAbandoned="true"               removeAbandonedTimeout="120" driverClassName="com.mysql.jdbc.Driver"               url="jdbc:mysql://localhost:3306/test_phonebook_db?autoReconnect=true"/> </Context>   
    This is the resource reference i have in my web app web.xml file :
    <resource-ref>       <description>DB Connection</description>       <res-ref-name>jdbc/phonebook_db</res-ref-name>       <res-type>javax.sql.DataSource</res-type>       <res-auth>Container</res-auth>   </resource-ref> 
    And this is my servlet class :
    package org.DB;  import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; import javax.naming.*; import javax.sql.*; public class TestDB2 extends HttpServlet { private Connection conn ; private Statement stat ; private ResultSet rs ; private int counter; private Object rsValue; public void init() {     try {             InitialContext ctx = new InitialContext();             DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/phonebook_db");             conn = ds.getConnection();             }         catch(Exception e) {               e.printStackTrace();         }     }     public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {         try {           stat = conn.createStatement();           rs = stat.executeQuery("SELECT * FROM phones_table");            } catch (SQLException sqle) {         sqle.printStackTrace();         }      response.setContentType("text/html; charset=utf-8");     PrintWriter out = response.getWriter();         String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " + "Transitional//EN\">\n";     out.println(docType +"<HTML>\n" + "<HEAD><TITLE>PhoneBook entries</TITLE></HEAD>\n");         counter = 0;     try {         while (rs.next()) {             out.println("<h4>Entry no. " + (++counter) + "</h4>");             out.println("<table width=\"75%\" border=\"1\">");             out.println("<tr>\n"+ "<td width=\21%\"><b>LastName:</b></td>\n"+ "<td width=\"79%\">");             out.println((((rsValue = rs.getObject("LASTNAME"))==null || rs.wasNull())?                 "":(rsValue.toString())));             out.println("</td>\n</tr>\n" +  "<tr>\n"+                     "<td width=\21%\"><b>FirstName:</b></td>\n"+ "<td width=\"79%\">");             out.println((((rsValue = rs.getObject("FIRSTNAME"))==null || rs.wasNull())?                 "":(rsValue.toString())));             out.println("</td>\n"+ "</tr>\n"+                     "<td width=\21%\"><b>Phone:</b></td>\n"+ "<td width=\"79%\">");             out.println((((rsValue = rs.getObject("PHONE"))==null || rs.wasNull())?                 "":(rsValue.toString())));             out.println("</td>\n" + "</tr>\n" +                     "</table>\n"+ "<br>\n<br>");         }     } catch (SQLException sqle) {         sqle.printStackTrace();     }     out.println("</body>\n"+             "</html>"); } public void destroy() {     try {         rs.close();         stat.close();         conn.close();     } catch (SQLException sqle) {         sqle.printStackTrace();         }     } }{code} Any suggestions?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thank you for your answer.Yes my servlet class is something more worse than horrible(i don't use the database connection correct i don't use the MVC pattern i use out.println() ) but i just tried to take a ready example and try to understand .So i write this servlet myself as a starting point :
    package org.DB;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.*;
    import java.sql.*;
    public class DBServlet extends HttpServlet {
        private Connection conn ;
        private Statement stat ;
        private ResultSet rs ;
        private int counter;
        String driver = "com.mysql.jdbc.Driver";
        String dbURL = "jdbc:mysql://localhost:3306/phonebookdb?user=**********&password=************";
        @Override
    public void init() {
         try {
                Class.forName(driver).newInstance();
                conn = DriverManager.getConnection(dbURL);
         }catch(Exception e) {
                  e.printStackTrace();
                  System.err.print("Unable to make connection ");
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
                out.println("<html>");
                out.println("<head>");
                out.println("<title>Servlet DBServlet</title>"); 
                out.println("</head>");
                out.println("<body>");
                out.println("<h1>Servlet DBServlet at " + request.getContextPath () + "</h1>");
                out.println("<br /><br /><br />");
                if(conn!=null) 
                    out.println("conn object : "+conn);
                out.println("</body>");
                out.println("</html>");
            } catch(Exception sq) {
                System.out.println("Exception" + sq.getMessage());
                out.close();
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
         public void destroy() {
         try {
             conn.close();
         } catch (SQLException sqle) {
             sqle.printStackTrace();
        @Override
        public String getServletInfo() {
            return "A Simple Servlet";
    }And it work for now.
    Edited by: pavlos555 on Oct 21, 2008 10:21 AM

  • JDBC/MYSQL Connection problems

    I'm new to using JDBC so I'm not sure if I'm simply doing something wrong in my code or if I've installed something incorrectly. I've got the JDBC connector/J installed properly as far as I can tell. At least when I run my code I'm not getting an error about the driver not being found. The problem I'm running into is that even though I've double and triple checked the authentication info I keep getting the following error:
    Exception in thread "main" java.sql.SQLException: Invalid authorization specification message from server: "Access denied for user: '[email protected]' (Using password: YES)"
    The actual connection commands I'm using are as follows:
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost/Test", "testusr", "testpwd");
    I've checked and rechecked the spelling of my mySQL user & password and as far as I can tell, they work just fine so I can't figure out why I would be getting this error. Any suggestions on things I can try or does anyone see any obvious errors in what I'm doing?

    The failure is caused not by the JDBC driver but by how the MySQL was configured
    when it was installed. By default, MySQL is configured to allow connections that
    are created only from within the localhost.
    The line
    DriverManager.getConnection("jdbc:mysql://localhost:3306/Test?user=testusr& password=testpwd") translates to "create a connection to MySQL running at 'localhost' and use the
    'testusr@<hostname.domain>' as user name and 'testpwd' as the password".
    If you can see, the <hostname.domain> is replaced with "other value" aside from
    the "localhost" which you expect, hence connection is denied.
    The '<hostname.domain>' is replaced with the value of either your IP address or
    hostname. Therefore, any connections created from outside the host where your
    server is running will be denied. Now, making the 'host' value set from
    'localhost' to '%' would tell MySQL that you are allowing connections created from
    outside the MySQL host to connect to the server.
    Another way to go around this is problem is to modify your
    "\Windows\system32\drivers\etc\hosts" OR "/etc/hosts" file and give
    your loopback address (127.0.0.1) another alias (aside from localhost), e.g.:
    127.0.0.1    localhost    <hostnameY.domain>
    192.168.1.1  <hostnameX.domain>  <hostnameY.domain>where you replace <hostnameY.domain> with the name/alias of your computer in
    the network. The domain is optional and depends upon the domain name that
    your network is using.

  • JDBC MYSQL Connection Problem

    Hi guys I have created a database called books in MySQL and I have the following code to test the link of connection. I am using Netbeans.
    import java.sql.*;
    public class jdbcexample1 {
    /** Creates a new instance of jdbcexample1 */
    public jdbcexample1() {
    * @param args the command line arguments
    public static void main(String[] args) {
    // TODO code application logic here
    Connection con = null;
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql:///books", "jhtp6", "jhtp6");
    if(!con.isClosed())
    System.out.println("Successfully connected to MySQL server...");
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    } finally {
    try {
    if(con != null)
    con.close();
    } catch(SQLException e) {}
    However my program when run gives me the exception message which is
    "Exception: com.mysql.jdbc.Driver"
    Before you tell me, I have put the "mysql-connector-java-3.0.14-production-bin" in the ext folder of jre and I have also appended the CLASSPATH as follows.
    ".;C:\PATH\mysql-connector-java-3.0.14-production-bin.jar;" which leads to the jre ext folder.
    What am I doing wrong, Have I missed something above and if not what could be wrong with my setup.
    Thanks!! :)

    Helo,
    I have just started with java, I am also using netbeans, I used similar code to test the link, the code gives the following error when compiled:
    java.lang.NoClassDefFoundError: JdbcExample1
    Exception in thread "main"
    Java Result: 1
    The code I used is a s follows:
    package com.stardeveloper.example;
    import java.sql.*;
    public class JdbcExample1 {
    public static void main(String args[]) {
    Connection con = null;
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql:///pet", "root", "siemens");
    if(!con.isClosed())
    System.out.println("Successfully connected to MySQL server...");
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    } finally {
    try {
    if(con != null)
    con.close();
    } catch(SQLException e) {}
    Pls help..
    Thanks..
    Hi guys I have created a database called books in
    MySQL and I have the following code to test the link
    of connection. I am using Netbeans.
    import java.sql.*;
    public class jdbcexample1 {
    /** Creates a new instance of jdbcexample1 */
    public jdbcexample1() {
    * @param args the command line arguments
    public static void main(String[] args) {
    // TODO code application logic here
    Connection con = null;
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con =
    DriverManager.getConnection("jdbc:mysql:///books",
    "jhtp6", "jhtp6");
    if(!con.isClosed())
    System.out.println("Successfully connected to MySQL
    server...");
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    } finally {
    try {
    if(con != null)
    con.close();
    } catch(SQLException e) {}
    However my program when run gives me the exception
    message which is
    "Exception: com.mysql.jdbc.Driver"
    Before you tell me, I have put the
    "mysql-connector-java-3.0.14-production-bin" in the
    ext folder of jre and I have also appended the
    CLASSPATH as follows.
    ".;C:\PATH\mysql-connector-java-3.0.14-production-bin.
    jar;" which leads to the jre ext folder.
    What am I doing wrong, Have I missed something above
    and if not what could be wrong with my setup.
    Thanks!! :)

  • Problem with JDBC ODBC connectivity

    I am trying to connect to MS access database with jsp page. This is sample from my js page :
    String SUN_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
    Class.forName(SUN_DRIVER);
    String aDataSourceName = "puneet";
    String url = "jdbc:odbc:" + aDataSourceName;
    Connection con;
    con = DriverManager.getConnection("jdbc:odbc:puneet","","");
    The last line gives me the follwoing error :
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    puneet is name of my datasource and it points to my .mbd file.
    I dont have anyusername or passwords for this daatsource.
    I am using Tomcat/4.1.18-LE and jdk1.4
    I have also added rt.jar in the classpath
    pls help
    pg4

    Hi pg4,
    May be your dsn is not pointing to .mdb file. Check it by putting your mdb file right where your code is and then user following syntax which is called dsn-less connection. It helps you to connect to the target mdb file with out any need of dsn.
    String url = "jdbc:odbc:;Driver={Microsoft Access Driver (*.mdb)}; DBQ=yourDBFile.mdb";
    regards,
    Humayun

  • DB connection using Tomcat

    Hi,
    Can I know how to get connected to DB using Tomcat. Any souce code of one sample prog. will be helpful.
    Uma

    You can try using the same procedure as you do with the other servers.
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()) - if you have the Oracle Thin driver. Otherwise no need for this step.
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:dbName", userid, password);

  • Problem in compiling servlet class - using Tomcat

    Hi,
    I have a servlet pgm that I'm trying to compile.I using Tomcat application server.I have my servlet class in D:\servlet_wrk\project1\src
    and my deployment descriptor in D:\servlet_wrk\project1\etc
    my CLASSPATH var is set to C:\Sun\AppServer\jdk\bin
    and
    my PATH var is set to C:\Sun\AppServer\bin.
    When I compile my servlet class Ch1Servlet.java in the command line from the directory
    D:\servlet_wrk\project1 using the command
    javac -classpath D:\applications\tomcat-5.5.12\common\lib\servlet-api.jar -d classes src/Ch1Servlet.java,
    it says error:cannot read: src/Ch1Servlet.java
    Can somebody help me to solve this problem and help me to compile my servlet class.
    Thanks.

    Thanks...as u said I tried putting dir & found that
    my file was saved as Ch1Servlet.java.txt instead for
    Ch1Servlet.java......So that was a problem.Now I'm
    able to compile.Oh, yeah. Notepad will do that to you. I think when you save in Notepad if you put quotes around the name "Whatever.java" then it won't add the .txt.
    But on compiling I'm getting the following error
    package java.servlet.* does not exist
    package java.servlet.http.* does not exist
    package java.io.* does not exist
    Do u the reason for this??? The servlet stuff is java[b]x.servlet. For the io stuff, I don't know, I'd have to see your code. Either you have a typo or a corrupt installation.

  • JDBC Thick connection using ADF

    Hi All,
    I am doing Thick Oracle connection using ADF but i am getting this error...
    java.lang.UnsatisfiedLinkError: no ocijdbc11 in java.library.path
    following is my code..
    try {
    Class.forName("oracle.jdbc.OracleDriver");
    Connection con=DriverManager.getConnection("jdbc:oracle:oci8:@dbndevp", "mfonline", "mfonline");
    System.out.println(con.isValid(1));
    } catch (Exception e) {
    e.printStackTrace();
    So how can i do it in ADF......
    -Thanks
    Edited by: Santosh Vaza on Dec 31, 2010 6:14 PM

    Suppose i have a backing bean class then how would i get connection to database, Suppose that i am using 2 connections to 2 different database.Case 1: If you are using ADF Business Components (or some other framework that implements "business services" layer)
    In this case ADF BC implement the "business services" layer in the application architecture and they are responsible for the interaction with the DB. You should encapsulate there all the program logic that interacts directly with the DB. You can invoke ADF BC methods from managed beans but you should not implement any direct DB operations in managed beans (in particular you should not open DB connections, parse and execute SQL statements in managed beans). If you need to work with 2 different databases, then you have to define 2 different ApplicationModules (with connections to these databases). There is an important disadvantage - ADF BC does not support global transactions (e.g. XA-compatible transactions), so if you need distrubuted transactions, then either you could use DB-links (if both databases are Oracle ones) or you will need a different framework.
    Case 2: If you are not using any framework that implements "business services" layer
    In this case you should not use DriverManager, but you could get DB connections from JDBC DataSources. In this way you would benefit from the connection pooling of the DataSources and you would avoid the heavy overhead of creating and closing DB connections. (When you close a DB connection acquired from a DataSource, in fact it is not closed but it is just checked back into the DataSource's connection pool).
    Dimitar

  • JDBC MySql Connectivity

    I'm not exactly sure how to connect my servlet to the database
    I downloaded the connector/j and pasted the jar file into
    C:\Program Files\Java\jre1.5.0_06\lib\ext\
    the program crashes out at this line
    Class.forName("com.mysql.jdbc.Driver");
    also not sure about this line
    String url ="jdbc:mysql://localhost:3306/bookdb";
    as my database isnt stored in localhost its in the MySql folder
    any help would be much appreciated. here's my servlet code
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class TestForm extends HttpServlet
         public void doGet(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException
              res.setContentType("text/html");
              PrintWriter out = res.getWriter();
              String name = req.getParameter("id");
              out.println("<HTML>");
              out.println("<HEAD><TITLE>Hello, " + name + "</TITLE><HEAD>");
              out.println("<BODY>");
              out.println("Helloo, " + name);
              out.println("test1");
              try {
                   out.println("test2");
              Statement stmt;
              //Register the JDBC driver for MySQL.
              out.println("test8");
              Class.forName("com.mysql.jdbc.Driver");
              //Define URL of database server for
              // database named mysql on the localhost
              // with the default port number 3306.
              out.println("test9");
              String url ="jdbc:mysql://localhost:3306/bookdb";
              //Get a connection to the database for a
              // user named root with a blank password.
              // This user is the default administrator
              // having full privileges to do anything.
              out.println("test10");
              Connection con =
              DriverManager.getConnection(
              url,"root", "squidgy");
              //Display URL and connection information
              out.println("URL: " + url);
              out.println("Connection: " + con);
              //Get a Statement object
              stmt = con.createStatement();
                   ResultSet rs = stmt.executeQuery("SELECT NAME FROM CUSTOMER");
                                  // Display the result set as a list
                                  out.println("<BODY>");
                                  out.println("<UL>");
                                  out.println("test6");
                                  // while there are more records in the table to be searched
                                  while(rs.next())
                                       out.println("<LI>" + rs.getString("name"));
                                       out.println("test");
                                  out.println("<UL>");
                                  out.println("test7");
              con.close();
              }catch( Exception e ) {
                        out.println("test3");
              e.printStackTrace();
    }//end catch
    out.println("test4");
              out.println("</BODY></HTML>");
    };

    as my database isnt stored in localhost its in the MySql folderWhere the data is stored is irrelevant. You will be running the MySQL server. It will find the data and respond to requests from the JDBC driver on port 3306. You might want to spend a little time reading the MySQL documentation, especially the part about how to configure and run the server.

  • Problems with jdbc:thin connection to oracle9i RAC

    Hi,
    I am having problems connecting to a 2 node RAC using jdbc:thin.
    Connecting directly to the nodes is no problem, but I get an exception when trying to use load balancing/failover.
    this is my connection string (URL):
    jdbc:oracle:thin:@(DESCRIPTION =
    (ADDRESS_LIST =
    (LOAD_BALANCE = on)
    (FAILOVER = on)
    (SOURCE_ROUTE = OFF)
    (ADDRESS =
    (PROTOCOL = TCP)
    (HOST = NODE1)
    (PORT = 1521)
    (ADDRESS =
    (PROTOCOL = TCP)
    (HOST = NODE2)
    (PORT = 1521)
    (CONNECT_DATA =
    (SERVICE_NAME = MYSERVICENAME)
    (failover_mode =
    (type = session)
    (method = basic)
    and this is some of the stack trace :
    java.sql.SQLException: Io exception: NL Exception was generated
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
         at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:418)
         at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:521)
         at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:325)
         at java.sql.DriverManager.getConnection(DriverManager.java:512)
         at java.sql.DriverManager.getConnection(DriverManager.java:171)
    Any help would be greatly appreciated.
    Regards,
    Christian

    Dear Maran,
    Yes! You can always increase the number of process and session to a higher limit at database end, but it won't be a feasible solution. Rather look into the areas which are the cause of this and try to solve them out.
    What if you increase these parameters at database end to accomodate more and more sessions, and allow them to use more and more resources like process, and still they keep on increasing rather than getting closed. It would be worthless use of Database server Reources.
    It is really very simple, just look for the SQL statements which are having last_call time a long back (from V$SESSION and V$SQLAREA or you may use tools like TOAD), and try to find out the reason why they are not releasing the connections back to Connection Pool. Check out these SQL statements in the application code and ensure Connection Handling is done over them.
    Some "RS.CLOSE" type of command is there in java (I am not sure with the proper syntax)
    Regards,
    Manoj.
    null

  • Problem with Grop Video connection using Panasonic...

    We're trying to do a Group Video between our three offices using a Mac laptop at the main office and Skype installed TV's at the other locations. We can connect to the first office which is using a Panasonic Skype ready TV fine, picture quality is go. When we try a connect the thrid party we can not see anyone and it gives us a message that the other sides do not the latest Skype software. How can we get Panasonic to update their Skype version?

    Did you ever get a solution to this problem?

Maybe you are looking for

  • How can I print multiple images on one sheet:  PSE 10/Mac?

    When printing, I can have all of my images in the dialoug box - but cannot figure out how to get more than one image on a sheet!  For example, I am printing several photos a 2x2, and want to put as many as possilble on 1 sheet instead of using a sepe

  • Has anyone else had the same problem with SYSMAN password resetting?

    I am a Oracle Support Administrator and have posted a SR with Metalink and just wanted to ask the community if they have had any of the same problems. I am remotely accessing a customers Grid Control via VMWare software and over the past couple of we

  • Question on Formula Creation in Numbers

    I am creating a form that involves two columns, both of which involve the same formulation. On the first I start with $200,000.00, which increases in increments of $50,000 up to $2,000,000. Is there a way to set up a stepper that would accomplish thi

  • B&W HTM61 S2 arrived with gouged box and broken foam padding

    Purchased a Bowers and Wilkins HTM61 S2 at a Newington, NH store and had it shipped to my home. It arrived with a corner showing signs of being dropped, a large gouge on one corner, and when opened the foam inserts were broken and in pieces. My conce

  • Not opening all my previously opened windows, many are blank!

    Why does Safari randomly choose not to open all my previously open windows? Sometimes up to half the tabs/windows show up BLANK. Often, I'll see the headings written in the tabs in the toolbars, but when I go to them, they are blank, and I must re-en