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.

Similar Messages

  • 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!! :)

  • PHP and MySQL Connection problem

    I am trying to make a PHP MySQL on a remote server connection in Dreamwesaver CS3.
    When I enter the information (host, user, password, etc.) and hit TEST, I get the following error message.
    "Access Denied. The file may not exist, or there could be a permission problem. Make sure you have proper authorization on the server and the server is properly configured."
    I know the user, password, etc. work, as I can access the MySQL database with other software.
    I checked with my host and they say there are no permission problems on their end.
    I have checked the settings on the Test Server page in Site Setup and everything looks correct and works there.
    I have not seen this particular problem described in other forum postings (although there are a LOT of postings on this topic!).
    Any help would be appreciated.

    I thought my testing server was the remote server and is always on as far as I know. I don't know how to turn it on or off.
    Is there some other testing server that I should be aware of?
    Frank
    Date: Wed, 3 Jun 2009 15:43:02 -0600
    From: [email protected]
    To: [email protected]
    Subject: PHP and MySQL Connection problem
    I know you are using remote, but is your testing server on? if not turn that on and see if that does it. it just happened to me working on remote server and could not get mysql conn to work, until I turn on my testing (developer server), then I was able to connect to mysql and the tables that I created in phpmyadmin remotly was downloaded.
    >

  • 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");

  • 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

  • JDBC and MySQL connectivity problem

    The code i hav attached generates Connectivity exception.. the prob is with the part in bold.. can anyone help
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class testconn {
      public static void main(String args[]) {
        Connection con = null;
                String serverName = "localhost:8080";
            String mydatabase = "imagedb";
            String url = "jdbc:mysql://" + serverName +  "/" + mydatabase; // a JDBC url
            String username = "am";
            String password = "ta";
        try {
          Class.forName("com.mysql.jdbc.Driver");
         con= DriverManager.getConnection(url, username, password);
          if(!con.isClosed())
            System.out.println("Successfully connected to " +
              "MySQL server using TCP/IP...");
        } catch(Exception e) {
          System.err.println("Exception: " + e);
        } finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    }

    I had such issue too, and I fixed it by adding in the environment variables the CLASSPATH entry that pointed to all the directories containing the .jar needed for the applications.
    for example I used jodbc folder to connect mysql database (I installed last version and I got same issue than yours and it seems to be a 'connector' issue, exactly the same issue than yours) I got something like
    CLASSPATH=my root dir/the java dir/the lib dir/jodbc;my root dir/the java dir/other important libs containing .jar files;
    This is what I got for the issue, still working around (at the level of mysql all is ok, ...)
    Microsoft Windows XP [version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\Hurukan>java ConnectJODBC brol
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at ConnectJODBC.main(ConnectJODBC.java:108)
    [exception] -- la valeur de 'con' est nulle (DriverManager � retourn� une valeur
    nulle)
    C:\Documents and Settings\Hurukan>set
    APPDATA=C:\Documents and Settings\Hurukan\Application Data
    CLASSPATH=c:\Program Files\Java\jdk1.5.0_06\lib;c:\Program Files\Java\jdk1.5.0_06\dev;\c:\Program Files\Java\jdk1.5.0_06\lib\jodbc;
    Here is the code that generated this exception
    String dburl="jdbc:mysql://127.0.0.1/nosdisques"; // should be next passed by command line
    String password="**scrambled**";
    String username="**scrambled**";
    Connection con=null;
    Statement stmt=null;
    ResultSet res=null;
    String requete="";
    String strToWrite="";
    // Connexion � la base de donn�e
    // Won't work with mysql 5.0.18, mysql connector 3.51.12 is installed [???]
    // Previous tests with 5.0.18 were running good, that has started with the last os restoration (and the connector was different of course...)
    // tried to retreive older version of the mysql connector
    try
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con=DriverManager.getConnection(dburl,username,password);
    System.out.println("Nous sommes connect\u201as \u2026 la base " + con.getCatalog());
    catch(SQLException sqlex)
    System.out.println("[sqlexception]\n");
    System.exit(3);
    catch(Exception ex)
    ex.printStackTrace();
    if(con == null)
    System.out.println("[exception] -- la valeur de 'con' est nulle (DriverManager \u2026 retourn\u201a une valeur nulle)\n");
    System.exit(4);
    System.out.println("Impossible to join database, access denied\n");
    System.out.println("Verify settings (mysqld or firewall)\n"); System.exit(2);
    Maybe the drivers used (last one: connector/j 3.1.12). The .jar file is in the %classpath% directory c:\Program Files\Java\jdk1.5.0_06\lib.
    Can't really understand why this code won't run anymore, ...
    I took a look on the other computer where the same code is running ok.
    These are the differences:
    mysql server is 5.0.18 on the other computer the version is 3.23.41
    mysql connector is 3.51.12 on the other computer the version is 3.0.10
    access rights are the same because the database is the dumped one from 3.23.41 to 5.0.18, and I'm quite good with the dbms management (I'm IT developper in fact, trying to take over java technology ;) )
    in this case this is not a sql error but java error.
    the jar file is set to the %classpath% folder on both computers
    I copied the jar from the other computer, removing the new .jar file and... it failed, exactly the same issue
    Still working around, ...
    Dimitri

  • MySQL Connectivity problem

    Hi all,
    I am new to JSP. I am using Eclipse 3.2. with all lpugins. The following code throws an error. Pleas help me.
    <html><body>
    <%@ page import="java.sql.*, java.lang.ClassNotFoundException"%>
    <%
         String connectionURL = "jdbc:mysql://localhost:3306/online_hotel_booking";
         String userName = "root";
         String password = "root";
         // Load the driver class and establish a connection
         try {
              Class.forName("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection(connectionURL,userName,password);
              Statement stmt = con.createStatement();
              ResultSet rs = stmt.executeQuery("select * from hotel_details");
              while (rs.next()) {
                   out.println(rs.getString(1));
                   out.println(rs.getDate(2));
              /* closing the connection */
              rs.close();
              stmt.close();
              con.close();
         catch (Exception e) {
              out.println("Exception!"+e);
    %>
    </body></html>It throws ClassNot FoundException: com.mysql.jdbc.Driver
    Thanks in advance

    JDBC questions should be posted in the JDBC forum: http://forum.java.sun.com/forum.jspa?forumID=48
    If you take the time to look the active topic listing of the JDBC forum, you'll see that you're not the only one who encountered the problem. Yesterday I answered similar topic on this issue.

  • JSP Mysql Connection Problem

    Hi Friend,
    I am facing some problem in connecting mysql with jsp .
    When I try and connect to mysql with the following connection string
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdhiraj?user=root&password=dh");
    Statement statement     = con.createStatement();
    I get an error :
    java.sql.SQLException: Communication link failure: Bad handshake
    I don't know what is wrong,
    as I had tested mysql using telnet and it connects and executes sql nicely.
    Waiting for ur reply,
    Dhiraj Agrawal
    mail to : [email protected]

    Hi,
    You need to make sure that , you have given correct database name, user id and password in the connection url. and also check the jdbc driver is loaded properly. If your mysql is running in the standard port, you need not give the port as 3306.
    Here is the example :
    import java.sql.*;
         Notice, do not import org.gjt.mm.mysql.*
    or you will have problems!
    public class XampleClass
    public static void main(String[] Args)
    try {      
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    catch (Exception e) {
    System.err.println("exception while loading
    driver.");
    e.printStackTrace();
    try {
    Connection C = DriverManager.getConnection(
    "jdbc:mysql://localhost/test?user=myuser&password=mypwddb");
    // Do something with the Connection
    catch (SQLException e) {
    System.out.println("Exception: " + e);
    This is the format for conenction url :
    jdbc:mysql://[hostname][:port]/dbname[?param1=value1][&param2=value2]...
    Hope this helps you.
    Thanks,
    Senthil_Slash

  • MySQL connectivity Problem URGENT plz

    Hi
    plz can any one help me... its urgent
    i need java to connect to MySQL database.with mm.mysql.Driver
    the following sample code is just copied from the site and made changes in hostname, dbname and username.
    classpath has been given correctly for the mm.mysql.Driver package (mysql.jar).
    Thanx in advance....
    Result
    compilation --> success
    while executing i get the following Error.
    java.sql.SQLException: General Error: null
         at org.git.mm.mysql.connection.<init>(Connection.java)
         at org.git.mm.mysql.Driver.connect(Driver.java)
         at java.sql.DriverManager.getConnection(DriverManager.java: 515)
         at java.sql.DriverManager.getConnection(DriverManager.java: 197)
         at JDBCDemoCreate.getConnection(JDBCDemoCreate.java: 36)
         at JDBCDemoCreate.<init>(JDBCDemoCreate.java: 14)
    java.lang.NullPointerException
         at JDBCDemoCreate.<init>(JDBCDemoCreate.java: 17)
         at JDBCDemoCreate.main(JDBCDemoCreate.java: 47)
    Here is the code. can any one try this !
    // JDBCDemoCreate.java
    1.     import java.util.*;
    2.     import java.sql.*;
    3.
    4.     public class JDBCDemoCreate {
    5.
    6.     private static final String hostname = "hostname";
    7.     private static final String port = "3306";
    8.     private static final String database = "dbname";
    9.     private static final String username = "username";
    10.     private static final String password = "";
    11.
    12.     public JDBCDemoCreate() {
    13.
    14.          Connection c = getConnection();
    15.
    16.          try {
    17.               Statement s = (Statement)c.createStatement();
    18.               s.executeUpdate("CREATE TABLE rich ( id int primary key, name char(25) )");
    19.          } catch ( Exception e ) {
    20.               e.printStackTrace();
    21.          }
    22.
    23.     }
    24.
    25.     private Connection getConnection() {
    26          // Register the driver using Class.forName()
    27.          try {
    28.               Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    29.          } catch ( Exception e ) {
    30.               e.printStackTrace();
    31.          }
    32.
    33.          // ask the DriverManager for a connection to the database
    34.          Connection conn = null;
    35.          try {
    36.               conn = DriverManager.getConnection("jdbc:mysql://" + hostname +
    37.                                                                      ":"+ port +"/" + database +
    38.                                                                      "?user=" + username +
    39.                                                                      "&password=" + password );
    40.          } catch (Exception e) {
    41.               e.printStackTrace();
    42.          }
    43.          return conn;
    44.     }
    45.     
    46.     public static void main( String[] args ) {
    47.          new JDBCDemoCreate();
    48.     }
    49.}

    Hi!
    You can try with this code coz, i worked with this code only and then i can talk to the database.
    Connection con;
    Class.forName("org.gjt.mm.mysql.Driver";
    con = DriverManager.getConnection("jdbc:mysql:///db?user=root&password=");
    Try it out!
    Queries regarding this is welcome. Either in this forum itself or u can contact in the mail, the id is
    [email protected]
    Regards,
    dinesh

  • DW CS3 to MySql connection problem

    I have DW CS3 on Windows Vista. I have installed the Apache
    web server and MySql. I've associated the Apache server for testing
    and it works fine for page displays, so when I make a change to a
    page and hit F12 it is uploaded to the test environment and
    displayed in a browser.
    MySql is up and running, I can log onto it with the MySql
    admin client and see my database (just a testing one).
    When I try to test the sql connection I get the message "An
    unidentified error has occurred" and I don't have access to the
    data.
    When I try to test a PHP page it is treated as a file object
    and not processed, just loaded for editing.
    I don't know what I've set up wrong, any help
    appreciated.

    Was this issue resolved?
    I have the same problem now. DW was working fine the one day and the next when I started it it had this connection problem.
    I am testing on my local PC. My sites is at http://localhost/
    All my connection are working because if I go to http://localhost/index.php I can see my site and if I go to http://localhost/register.php I can even register a new user. It will include the new user details in the data base and everything is working fine. So there is nothing wrong with the connection.
    In DW I do have http://localhost/ on the Local Info screen. As I said, all was working fine on the current setup the one day and the next day it did not want to work.
    Seems like a very common problem.
    I want to buy CS4 and surely hope that the problem has been fixed by now.

  • 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.

  • MySQL connectivity problem: no validation table provided

    hi there,
    As a superbeginner, on my Mac G4 OSX 10.4 I am trying to add a MySQL database in Sun JSC 2.1, following the tutorial:
    Creating Database Server Types and Data Sources
    So far I have managed to
    -install mysql 3.1.14 and
    -add this as a new database server
    When I try to add a data source, I cannot select a validation table (message: No Tables were found. Check your connection information), and I cannot find in the manuals how to make one. When I test the connection the connection status is succeeded, but the validation table status is failed (No validation table provided...)
    In a seccond attempt, I also installed MySQL 4.1.21 and navicat (in which the connection seems to be good), but I cannot figure out how to connect this version 4.1.21 to the JSC, because 4.1.21 differs in installation (it uses an installation package in stead of a zipped folder) which is not covered by the tutorial.
    Any hints on one of the two attempts, or a suggestion for a database which might give a beginner like me less problems to connect? Thanks a lot.
    [email protected]

    I think the simplest way is:
    create a table:if you have mysql 5.x you can di it with mysql tools (mysql administrator or mysql query browser), if you have a non graphical version of mysql you have to create the table with prompt.
    Create table Paziente (
         codice_fiscale_paziente Char(20) NOT NULL,
         nome Char(20),
         cognome Char(20))
         ENGINE = MyISAM;
    than open JSC (it doesn't have a jdbc driver installed to work with mysql, you have to download from mysql website and install in jsc)
    servers--> right click -->add data source
    than :
    data source name : the name you want to use
    server type: mysql
    database name : your's database name
    if you have user autentication in your db, set user and password
    set the correct db url
    and... test connection
    it should work

  • JDBC SqlServer connection problem

    Hi,
    I'm trying to connect to a local Sql Server database. I started out connecting to a database on another computer on the network by using the following code:
    //Set up connection to database
    String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String serverName = "10.42.8.102";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String databaseName = "traffic";
    String url = "jdbc:microsoft:sqlserver://" + mydatabase +";databaseName="+databaseName+";";
    String username = "sa";
    String password = "foobar";
    // Load the JDBC driver
    Class.forName(driverName);
    // Create a connection to the database
    connection = DriverManager.getConnection(url, username, password);
    This worked fine. However, when I started trying to connect to a database on my own computer, I started having problems. The database I'm trying to connect to is listed under the node "TERRAIN\BEATTHETRAFFIC" in SqlServer's Enterprise Manager. The database name is still traffic, and the user name and password are unchanged. My new code is as follows:
    String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String serverName = "localhost/TERRAIN/BEATTHETRAFFIC";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String databaseName = "traffic";
    String url = "jdbc:microsoft:sqlserver://" + mydatabase +";databaseName="+databaseName+";";
    String username = "sa";
    String password = "foobar";
    // Load the JDBC driver
    Class.forName(driverName);
    // Create a connection to the database
    connection = DriverManager.getConnection(url, username, password);
    I have also tried the following as the serverName:
    "TERRAIN\\BEATTHETRAFFIC"
    "localhost/TERRAIN\\BEATTHETRAFFIC"
    "127.0.0.1/TERRAIN\\BEATTHETRAFFIC"
    I have tried the above with / instead of \\ as well.
    With these, I get the error:
    [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
    I have also tried doing
    "localhost:TERRAIN\\BEATTHETRAFFIC" and
    "localhost:TERRAIN/BEATTHETRAFFIC" and used 127.0.0.1 instead of "localhost" as well.
    but with these I get
    [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL.
    I'm honestly at my wits' end here. I haven't really tried to connect to a Sql Server database before, and haven't done much work with connecting to databases in general, so maybe I'm making some glaringly obvious mistake, so if anyone could point it out, I'd be very grateful.

    For the value of serverName, you need to use an Internet-style host name, or an IP-address, not a Windows resource name.
    Examples of an internet-style host name are:
    this_host
    this_host.my_company.com
    Names with slashes in them are not Internet-style.
    The requirement is that name be something that your operating system can convert to an IP address. At least on newer versions of Windows (and most versions of Unix/Linux) you can find out the host name, with the "hostname" command. On windows:
    Click the Start button.
    Click the Run... link
    Enter "cmd" into the command line and click OK ( a new command window will open)
    In the new command window, enter "hostname" and hit enter. The system will give you the host name you need to use (upper/lower case does not matter).
    To confirm that the name ought to work, in that still-open command window, enter "ping [whatever the host name is]". You should get about 10 lines back that includes 4 lines that begin with "Reply from [your IP address] ..."

  • DW CS4 MySQL Connection Problem

    I know this one has been covered before but i've been trawling through posts for the past 2 days and still haven't solved my problem.
    I remember from using MX Studio and Ultradev that setting up a connection could prove challenging. It seems that CS4 is just as user-unfriendly in this regard. I know that the settings i'm using for the connection must be correct as i'm using them to successfully connect to the database and display its records using a hand-coded page. I've tried disabling Kaspersky and Windows Firewall but to no avail. I noticed one difference between the php script that dw attempted to make and mine is that i'm using mysqli whereas the dw version just refers to mysql. When I click on the Select button to try and select the database i just get  "An unidentified error has occurred" - about as much use as a chocolate fireguard - well done to the dw development team for that pearl of wisdom. Is dw trying to find my databse somewhere where it's not located? I noticed that C:/InetPub and its subfolders are marked "read only" but when you uncheck this, it reverts to read only - i don't know if this may have something to do with my inability to set up a connection. I managed to manually set up MySQL, PHP and Apache without problems but this has got me beat. Is it bad design in dw or am i just stupid? Don't answer that! Any help would be greatly appreciated as i know there's a lot of good stuff in dw if i could only make a connection (and i'm on a 30 day trial with this) Why should something that looks so easy be so difficult! Thanks, Mark

    Hi PZ,
             You're correct! I just managed to get my connection to work. I looked in my php.ini file and it only had extension=php_mysqli.dll at the bottom of the page (the dll file to which this refers was in the ext folder). So, I just added extension=php_mysql.dll to the end of the php.ini file then downloaded the PHP 5.2.13 zip package from http://www.php.net/downloads.php and then copied the file php_mysql.dll into the ext folder. I got the clue about mysqli not being supported after i'd carried out a Site > Advanced > Remove Connection scripts - that at least gave me a message "Your PHP Server doesn't have the MySQL module loaded or you cant use the mysql(p) connect functions" - before i did this i just got a useless "An unidentified error has occurred" which left me no further forward. Thanks for your help!

  • Migration from MySQL - connection problem

    I've just installed OMWB 1.3.1 for WINDOWS and created repository in ORACLE 8.0.5 DB.
    When I enter Source Database Details in Capture Wizard and push Next button nothing is happened. In OMWB log-file I've found the following message among many others:
    Exception occurred during event dispatching:
    java.lang.NoClassDefFoundError: org/gjt/mm/mysql/Driver
    at java.util.Vector.<init>(Vector.java:128)
    The directory C:\Oracle\oracle81\Omwb\drivers\
    is empty while in CLASSPATH env variable I've found the following item:
    C:\Oracle\oracle81\Omwb\drivers\mm.mysql.jdbc-1.2a
    If anybody could help me to solve this problem, please let me know.
    Thank you in advance.
    null

    Hi Vladimir,
    I send you a message from the Migration Workbench team that solved my problem. I hope this will resolve yours too.
    Bye,
    Pierfrancesco
    Hi Pierfrancesco
    MySQL 3.22, 3.23 Requirements
    In order to migrate from MySQL to Oracle, you must install the MM MySQL JDBC
    driver release 1.2a on the same system as the Migration Workbench. You can
    obtain this by downloading the MM MySQL JDBC driver from the WorldServer Web
    site at:
    http://www.worldserver.com/mm.mysql
    Copy and unzip the mm.mysql.jdbc-1.2a.zip file to your
    %ORACLE_HOME%\Omwb\drivers directory. This automatically creates a new
    directory called
    mm.mysql.jdbc-1.2a within the drivers directory.
    Can you please verify that you have this driver extracted to the above
    specified directory. Another check you can do is see whether all the files in
    the zip
    have extracted.
    Please refer to the Release notes which you have access to by selection the Help
    drop down menu in the Workbench.
    I hope this helps
    Best regards
    Oracle Migration Workbench Support
    null

Maybe you are looking for