Problem connecting to MySQL thro Applet using JDBC

Hi,
I'm trying to use an applet to connect to MySQL thro JDBC. The applet, the IE client that loads the HTML, and MySQL all reside on the same machine. But I'm getting the following error:"ClassNotFoundException: com.mysql.jdbc.Driver". But I'm able to connect using a Java application and run and display SQL query results. Any ideas are highly appreciated. Here're are the two pieces of code:
/****** Java Application *****/
import java.sql.*;
public class MySQL_App {
public static void main(String args[]) {
          String url = "jdbc:mysql://localhost/test";
     try {
               Class.forName("com.mysql.jdbc.Driver");
     catch(java.lang.ClassNotFoundException e) {
               System.err.print("ClassNotFoundException: ");
               System.err.println(e.getMessage());
/****** Java Applet *****/
import java.awt.*;
import javax.swing.*;
import netscape.javascript.*;
import java.sql.*;
public class MySQL_Applet extends JApplet {
     JSObject win;
     public void init() {
          win = JSObject.getWindow(this);
     public void callShowMessage() {
          String url = "jdbc:mysql://" + this.getDocumentBase().getHost() + "/test";
          String[] args = new String[1];
     args[0] = "" ;
     try {
          Class.forName("com.mysql.jdbc.Driver");
     catch(java.lang.ClassNotFoundException e) {
               args[0] += "ClassNotFoundException " + e.getMessage() ;
     win.call("showMessage", args);
}

mmm i, think that may here we've 2 possibles answers:
1) Did u read about "Applet Security"? my point is that you haven't acces to your local var "path" or "classpath".
2) Maybe u didn't especificate the MySQl path in ur classpath;
Check this 2 points

Similar Messages

  • How to Connect Microsoft SQL 2000 database using JDBC

    Hi all..
    I want to connect Microsoft SQL 2000 database using JDBC. I want from initial steps also. (about JDBC driver & its installation)
    Thankz

    Just checkout the SQL Server JDBC Driver Documentation at the manfacturer's site: http://msdn2.microsoft.com/en-us/data/aa937724.aspx

  • Problem to connect to mysql from servlet using a javabean

    Hi,
    I'm new here and beginner on java to.
    I have problem to connect to MySql database, by a connection javabean.
    It's the following: a HTML page calls a servlet and this servlet imports the package connection javabean.
    It has no problem when I establish the connection inside the servlet, with all its methods (public and private). But i want to separate the code connection from servlet.
    Detail: there is no problem, using the javabean to connect to MS Access database.
    I put "mysql-connector-java-3.1.12-bin.jar" file inside WEB-INF/lib application and common/lib directories.
    I set the classpath:
    SET CLASSPATH=%CATALINA_HOME%\COMMON\LIB\mysql-connector-java-3.1.12-bin.jar;%CLASSPATH%
    I think that the servlet cannot create an instance of javabean, because passed by catch exception of the servlet init method.
    But I don't know why.
    Please Why?
    Below there are the fragment of errors, servlet code e javabean code.
    Thank you.
    Zovao.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
    at CadServletFileBeanConexArq.doPost(CadServletFileBeanConexArq.java:47)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    Note: The line 47 is calling insertIntoDB javabean method.
    ========///////////////===============
    // Here is the servlet CadServletFileBeanConexArq.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    import conJdbc.*;
    public class CadServletFileBeanConexArq extends HttpServlet {
    public ConexPed connect = null;
    private String driver = "com.mysql.jdbc.Driver";
    private String URL = "jdbc:mysql://localhost:3306/cadastro";
    public void init( ServletConfig config )
    throws ServletException
    super.init( config );
    try
    connect = new ConexPed(driver, URL, "monty", "some_pass");
    catch ( Exception e )
    e.printStackTrace();
    connect = null;
    public void doPost( HttpServletRequest req,
    HttpServletResponse res )
    throws ServletException
    boolean success = true;
    String email, nome, sobrenome, produto, valor;
    email = req.getParameter( "Email" );
    nome = req.getParameter( "Nome" );
    sobrenome = req.getParameter( "Sobrenome" );
    produto = req.getParameter( "Produto" );
    valor = req.getParameter( "Valor" );
    res.setContentType( "text/html" );
    if ( email.length() > 0 && nome.length() > 0 && sobrenome.length() > 0 && valor.length() > 0 )
    /* inserting data */
    success = connect.insertIntoDB(
    "'" + email + "','" + nome + "','" + sobrenome + "','" + produto + "'", Double.parseDouble(valor) );
    //closing connection
    public void destroy()
    connect.fecharConexao();
    =============///////////////============
    Here is the JavaBean.
    package conJdbc;
    import java.sql.*;
    public class ConexPed
    public Connection connection;
    public Statement statement;
    public ConexPed (String driver, String urlServidor, String user, String password)
    try
    Class.forName(driver);
    connection = DriverManager.getConnection(urlServidor,user,password);
    catch (ClassNotFoundException ex)
    System.out.println("N�o foi poss�vel encontrar a classe do Driver: " + driver);
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel conectar ao servidor");
    try
    statement = connection.createStatement();
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel criar a statement");
    *Inserting data to database
    public synchronized boolean insertIntoDB( String stringtoinsert, double valor)
    try
    statement.executeUpdate( "INSERT INTO pedido values (" + stringtoinsert + " , " + valor + ");" );
    catch ( Exception e ) {
    System.err.println(
    "ERROR: Problemas ao adicionar nova entrada" );
    e.printStackTrace();
    return false;
    return true;
    * Close statement.
    public void fecharStatement()
    try
    statement.close();
    catch (SQLException ex)
    ex.printStackTrace();
    * close database
    public void fecharConexao()
    try
    connection.close();
    catch (SQLException ex)
    ex.printStackTrace();
    }

    Hi,
    I'm new here and beginner on java to.
    I have problem to connect to MySql database, by a connection javabean.
    It's the following: a HTML page calls a servlet and this servlet imports the package connection javabean.
    It has no problem when I establish the connection inside the servlet, with all its methods (public and private). But i want to separate the code connection from servlet.
    Detail: there is no problem, using the javabean to connect to MS Access database.
    I put "mysql-connector-java-3.1.12-bin.jar" file inside WEB-INF/lib application and common/lib directories.
    I set the classpath:
    SET CLASSPATH=%CATALINA_HOME%\COMMON\LIB\mysql-connector-java-3.1.12-bin.jar;%CLASSPATH%
    I think that the servlet cannot create an instance of javabean, because passed by catch exception of the servlet init method.
    But I don't know why.
    Please Why?
    Below there are the fragment of errors, servlet code e javabean code.
    Thank you.
    Zovao.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
    at CadServletFileBeanConexArq.doPost(CadServletFileBeanConexArq.java:47)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    Note: The line 47 is calling insertIntoDB javabean method.
    ========///////////////===============
    // Here is the servlet CadServletFileBeanConexArq.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    import conJdbc.*;
    public class CadServletFileBeanConexArq extends HttpServlet {
    public ConexPed connect = null;
    private String driver = "com.mysql.jdbc.Driver";
    private String URL = "jdbc:mysql://localhost:3306/cadastro";
    public void init( ServletConfig config )
    throws ServletException
    super.init( config );
    try
    connect = new ConexPed(driver, URL, "monty", "some_pass");
    catch ( Exception e )
    e.printStackTrace();
    connect = null;
    public void doPost( HttpServletRequest req,
    HttpServletResponse res )
    throws ServletException
    boolean success = true;
    String email, nome, sobrenome, produto, valor;
    email = req.getParameter( "Email" );
    nome = req.getParameter( "Nome" );
    sobrenome = req.getParameter( "Sobrenome" );
    produto = req.getParameter( "Produto" );
    valor = req.getParameter( "Valor" );
    res.setContentType( "text/html" );
    if ( email.length() > 0 && nome.length() > 0 && sobrenome.length() > 0 && valor.length() > 0 )
    /* inserting data */
    success = connect.insertIntoDB(
    "'" + email + "','" + nome + "','" + sobrenome + "','" + produto + "'", Double.parseDouble(valor) );
    //closing connection
    public void destroy()
    connect.fecharConexao();
    =============///////////////============
    Here is the JavaBean.
    package conJdbc;
    import java.sql.*;
    public class ConexPed
    public Connection connection;
    public Statement statement;
    public ConexPed (String driver, String urlServidor, String user, String password)
    try
    Class.forName(driver);
    connection = DriverManager.getConnection(urlServidor,user,password);
    catch (ClassNotFoundException ex)
    System.out.println("N�o foi poss�vel encontrar a classe do Driver: " + driver);
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel conectar ao servidor");
    try
    statement = connection.createStatement();
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel criar a statement");
    *Inserting data to database
    public synchronized boolean insertIntoDB( String stringtoinsert, double valor)
    try
    statement.executeUpdate( "INSERT INTO pedido values (" + stringtoinsert + " , " + valor + ");" );
    catch ( Exception e ) {
    System.err.println(
    "ERROR: Problemas ao adicionar nova entrada" );
    e.printStackTrace();
    return false;
    return true;
    * Close statement.
    public void fecharStatement()
    try
    statement.close();
    catch (SQLException ex)
    ex.printStackTrace();
    * close database
    public void fecharConexao()
    try
    connection.close();
    catch (SQLException ex)
    ex.printStackTrace();
    }

  • Help: Connecting Tomcat to CA-IDMS Using JDBC Type 4 Drivers (JNDI)

    Hi there,
    I have a rather interesting / complex problem......creating a connection to CA-IDMS from Tomcat using JDBC type 4 drivers (CA provide the type 4 driver).
    We have a zSeries 9 IBM mainframe running CA-IDMS r16.1, and I need to connect to the IDMS from Tomcat (running on Linux) using the JDBC Type 4 drivers provided by CA.
    At this stage I am struggling with the actual setup and configuration of Tomcat’s server.xml and web.xml files. These are the files where the JDBC configuration is set (I think). I have to setup the CA-IDMS part of the configuration, but that is a different problem. Basically there is a TCP/IP listener on the IDMS, waiting for incoming connections from the JDBC type 4 driver.
    I set up a Tomcat to MySQL connection using MySQL Connector / J, which is a similar kind of process to what I am trying to achieve with IDMS. MySQL connector / J came with a jar file which is placed in Tomcat’s lib folder, and then the JDBC setup for the web application is created in Tomcat's server.xml and web.xml files. You can then connect to the MySQL database using JSP and the configured JDBC driver / connection. The CA-IDMS Server comes with an idmsjdbc.jar file, which I think is the JDBC typr 4 driver. I think it needs to be placed in the Tomcat /lib folder, but I don’t know how to set up the configuration.
    There is a JDBC DriverManager which allows JDBC drivers to connect to CA-IDMS. The DriverManager recognises the following syntax:
    jdbc:idms://hostname:port/database
    This allows the JDBC driver running within Tomcat to connect to the IDMS which is running on the IDM mainframe. CA IDMS r16 supports direct connections from the Type 4 JDBC driver to the Central Version on IDMS. "hostname" is the DNS name or IP address of the machine where the CV is running, and "port" is the IP port that was specified for the listener PTERM (setup on the IDMS side).
    There is a caidms.properties file for the JDBC driver, which is used to specify user ID, password, and optional accounting information. It can also be used to specify physical connection information, allowing an application to connect to a CA-IDMS database without requiring the definition of an ODBC style data source. However, I don’t know where to place this file within the Tomcat setup.
    There is also an IdmsDataSource class. I don’t know where to configure this or how to set it up; the CA-IDMS Server manual states the following:
    This class implements the JDBC DataSource interface. It is used with an application server (Tomcat) providing Java Naming and Directory Interface (JNDI) naming service to establish a connection to a CA IDMS database. IdmsDataSource properties conform to the Java Beans naming conventions and are implicitly defined by public “setter” and “getter” methods. For example, the “description” property, which is required for all DataSource implementations, is set using the setDescription(String) method. The application server may use the java.lang.reflection methods to discover DataSource properties and provide an interface to set them, or may simply require that they are defined in some configuration file. IdmsDataSource properties are used to specify the connection parameters. These properties are the equivalent of the DriverPropertyInfo attributes described in the previous section and can be used to completely define the parameters needed to connect to a database. Like a URL, an IdmsDataSource object can also reference an “ODBC” style data source name, where the connection parameters are defined in the configuration file on Linux.
    Is there anyone that can try to point me in the right direction to setting up the JDBC connection? I am totally new to Java and so the instructions are not making much sense at the moment. Any help, hints, tips…..anything will be greatly appreciated as I have just hit a brick wall here. I can't find much to do with setting up the CA-IDMS Server JDBC type 4 driver online either....if anyone can point me to some resources that would also be extremely useful.
    Kind regards
    Jp

    You say you've managed to get the JDBC driver working
    in an application but not in a JSP. You also say that
    the error you get is
    "com.microsoft.jdbc.sqlserver.SQLServerDriver".
    I'd be willing to bet that the exception that you have
    got is a ClassNotFoundException. I.E. your application
    server hasn't found the JDBC driver classes. The
    application server probably doesn't use your current
    CLASSPATH to look for classes. It will be setup within
    the application server in some way and you'll need to
    check your app server documentation to see how it is
    done.
    Try replacing
    e.printStackTrace();with
    e.printStackTrace(out);to get a full stack trace of your error.
    ColTried it. Got this error when I tried to run the JSP.
    Incompatible type for method. Can't convert javax.servlet.jsp.JspWriter to java.io.PrintWriter.
              e.printStackTrace(out);
    I'm currently using Apache Tomcat 4.0.3 as my JSP/Servlet Container.
    I'm also using Type 4 MS SQL Server 2000 JDBC driver version 2.0 on my NT4.0 Server.
    Do I need to set my JDBC driver in my container? if so, how do I do that?

  • Problem connecting to MySQL DB

    I am having a problem connecting to my database with the most basic java code.
    The code I have been using is at bottom of message. It compiles fine, and runs ok too, but does not connect, it gets the Exception and displays the "Canot connect ..." message. From the command line I can use the mysql client with the same user and pass I am using in the program with no problems. Any ideas on something else that might be causing it? I have already downloaded driver and include the paths in the CLASSPATH. Thank you for any help!
    CODE:
    import java.sql.*;
    public class Connect
    public static void main (String[] args)
    Connection conn = null;
    try
    String userName = "testuser";
    String password = "testpass";
    String url = "jdbc:mysql://localhost/test";
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    conn = DriverManager.getConnection (url, userName, password);
    System.out.println ("Database connection established");
    catch (Exception e)
    System.err.println ("Cannot connect to database server");
    finally
    if (conn != null)
    try
    conn.close ();
    System.out.println ("Database connection terminated");
    catch (Exception e) { /* ignore close errors */ }

    Thank you so much.
    I tried searching for a while without finding any answers and right after trying printStackTrace the problem becomes so clear. It was a host problem, after adding the appropriate privileges I was able to connect.
    I think printStackTrace will come in handy for any debugging while developing applications.
    Thanks again!

  • Problem connecting to hosted sharepoint site using hotspot connection with Telstra 3G

    I have problems connecting to a hosted sharepoint website using hotspot conection - either the page doesnt load (IE) or I get repeated sharepoint authentication prompts (Firefox). The problem is specific to this hosted site, we can successfully load other webpages, and can access another companes sharepoint extranet using iPhone hotsot connection. I have tried changing the cellular data APN settings on the iPhone from telstra.iph to telstra.internet but this did not solve the problem.

    Look at the JSSE examples. You need to setup a key store, add the jsse jars to your classpath, yadda, yadda, yadda....

  • Cannot connect Oracle 7.2.2 using JDBC thin in JDevelper....

    When I try to connect Oracle 7.2.2 database using JDBC thin driver of Java 1.1.8 in JDeveloper, the connection manager refuse to connect the database and alert the minimum version supported is 7.2.3. But I know JDBC thin driver can connect database of 7.2.x onwards. Any way to workaround? Thank you.

    Hi Tian-liang,
    Try using Microsofts JDBC driver rather than Suns. Also search these forums, other have run into the same issue.
    Thank you
    Don

  • Memory Leak when TOMCAT connects to Oracle 10g RAC using JDBC Thin driver.

    We had experienced Memory leak when a Oracle 10g (10.2.0.3) RAC node was evicted. TOMCAT app server is connecting to the Oracle 10g RAC database instances using JDBC 10.2.0.3 thin driver.
    Anyone had similar experience?
    Any ideas? Any bugs reported/fixed?
    Thanks,
    Raj

    If you're doing XA, we absolutely do not support
    driver-level load-balancing OR failover. Use neither.
    For non-XA, you can use driver-level failover. For
    non-XA, you could set load-balancing, but it won't
    help because we get connections from the driver,
    and keep them indefinitely, so the driver never gets
    the chance to affect which connections the pool
    uses after that.

  • Connecting with Unix user/password using JDBC

    1) Is it possible to connect on a java program, with JDBC, using the Unix autentification ?
    With the JDBC thin client I use :
    DriverManager.getConnection("jdbc:oracle:thin:@<ip addresse>:<listener entry port>:<SID>","<user>","<password>");
    2) What Java syntaxe may I use, not to give the <user>/<password> in my java program ?
    I want to lauch my java program from a shell script (UNIX). The Unix's user is know in my Oracle database.
    3) Is it a secure way ?
    Thank's

    For what it's worth, I have not yet found a way to do this, either. But since it's not critical for me, I have given up on it, for now. I have not found anything on OTN nor in the Oracle documentation that explains how to do this. Sorry :-(
    Good Luck,
    Avi.

  • Problem connecting to Mysql using JDBC

    Hi Everyone,
    I am trying to connect Mysql ad java applet and I am using the Mysql jdbc connector.
    I Took the mysql-connector-java-5.0.8-bin.jar file and put that in the library of jdk.
    Now i used the following code to connect to the database using Netbeans.
    package testmysql;
    import java.sql.*;
    public class Main
    public static void main (String[] args)
    Connection conn = null;
    try
    String userName = "root";
    String password = "";
    String url = "jdbc:mysql://localhost/rpms";
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    conn = DriverManager.getConnection (url, userName, password);
    System.out.println ("Database connection established");
    catch (Exception e)
    System.err.println ("Cannot connect to database server");
    finally
    if (conn != null)
    try
    conn.close ();
    System.out.println ("Database connection terminated");
    catch (Exception e) { /* ignore close errors */ }
    But it displays Cannot connect to database server
    thoughMysql server is running.
    Can anyone tell me wats the prob in this.
    thanks

    String url = "jdbc:mysql://localhost/rpms";
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    Is rpms the MySQL database?
    Is the database on the default port 3306?
    Is the MySQL JDBC JAR file in the classpath of the applet?
    newInstance() is not required to be invoked unless using <= JDK 2.0
    Replace:
    catch (Exception e)
    System.err.println ("Cannot connect to database server");
    with:
    catch (Exception e)
    System.err.println (e.getMessage());
    Edited by: dvohra09 on Apr 10, 2009 10:54 PM
    Edited by: dvohra09 on Apr 10, 2009 10:55 PM
    Edited by: dvohra09 on Apr 10, 2009 10:58 PM

  • Using D. Power's CS5 book, having problems connecting to MySQL

    I posted this yesterday on another, similar thread.  I'm reposting as a stand alone problem in hopes of finding an answer.  Thank you for any help.
    I am using Mr. Power's book to learn PHP for Dreamweaver CS5. I'm on a Windows 7 pro system. I followed the directions to install XAMPP but couldn't install b/c port 80 is being used by "NT Kernel & System". I changed the port from 80 to 88 both places in C:\xampp\apache\conf\httpd.conf (using the Apache Friends forums) which then worked.
    When trying to finish up the exercise at http://www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articl econtentAdobe_numberedheader_2, everything works great using http://localhost:88/php_test/ until the end. I can't get the MySQL to work.
    I set everything according to the directions on http://localhost:88/phpmyadmin . I've set up a user account called 'testUser'@'localhost:88' with the password 'xyz'. I put in the information as:
    Connection Name: connTest
    MySQL Server: localhost:88
    User Name: testUser
    Password: xyz
    Database: php_test
    When I either click on "select" (for the database) or click "test", the "File Activity - localhost" box comes up and goes to "(Not Responding)" status within a few seconds. The box is white the entire time, the text I'm coping comes from the header bar. After a minute or two, a box comes up saying "a server timeout has occured. Possible reasons: 1. Make sure web server is up and running 2.verify ODBC DSN exists on test server". Not sure what to do from there. (If I've clicked on the "select" button by database, Dreamweaver will lock up so I have to shut down and restart b/c it keeps going back to the "File Activity" box.)
    I've also tried having MySQL Server: "localhost". Then I get a MySQL error #1045 Access denied for user 'testUser' @ 'localhost' (using password:YES) - but I know the user name & password are correct. I've tried retyping both 10+ times! This is very frustrating for me, any help is much appreciated.
    ....I forgot to add the XAMPP is running in the background and shows Apache and MySQL running while I'm doing all of this..
    Also, when I set up the user name 'testUser' for php_test, on the "host", I selected "local" then defined the name as 'localhost:88'

    Anyone have ANY suggestions?!?
    I've installed/uninstalled XAMPP probably 5 or 6 times, done Revo uninstalls, used CCleaner to clean up my computer, rebooted and rebooted, gone down to XAMPP 1.7.3 done all the above again 2-3 times....nothing is working.  I keep having the same problem when I try to link the sql to the php page.
    I've also gone into the sql file and change the host to "localhost:88" which didn't change a thing.

  • HELP:Problem in creating a temporary CLOB using JDBC connection pooling

    Hi All,
    i am inserting a large xml document in an xml type column by creating a temporary clob of this document
    tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    I am not having any success getting the following statement working using a JDBC connection pool rather than a hard coded URL connection
    it works with:
    "jdbc:oracle:thin:@server:port:dbname" connection
    Does NOT work with:
    datasource.getConnection()
    Does any one know how to successfully get this to work?
    urgently plz........

    Hi Dharmi
    Here is a quote of Dafna's post in [another thread in this forum|Re: Copy VC controls]
    CE7.1.1 will be released at September 2008 for ramp-up customers.
    There are many improvements and new capabilities in the new release of Visual Composer for CE7.1.1. Among the new features you can find:
    The missing features from Visual Composer 7.0 (Html view, portal Eventing support (EPCM), JDBC, Undo/Redo, and more..)
    Many layout & modeling improvements
    Additional ALV table functionality - export to Excel, switch to chart, configure ALV behavior at design time
    Integration of Visual Composer in Eclipse - additional entry point to the Visual Composer models from the NWDS. This integration provides the option to add a WD component (in case of missing functionality in Visual Composer), as a black box component to the Visual Composer model. Right-clicking the component will open the Web Dynpro perspective for creating/modifying the component.
    Regards,
       Shai

  • Problems connecting to MySql on GoDaddy

    Hi!
    Don't know if it's the right place to ask, but I'm stuck with a problem.
    I've just bought my domain from GoDaddy.com and set a MySql database there. However, when I try to login to the server using the following info my Java application refuses to create a connection.
    String urlDatabase = "jdbc:mysql://mysql server/databasename"; String user = "databasename"; // on godaddy the db and user are the same String password = "mypassword";
    The same code used to connect to the database works clean and smooth on my local machine.
    After I construct the connection string it throws me the following errors:
    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1119) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2257) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:784) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:354) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:284) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at magenta.model.database.connectionpool.JDCConnectionPool.getConnection(JDCConnectionPool.java:62) at magenta.model.database.connectionpool.JDCConnectionDriver.getConnection(JDCConnectionDriver.java:36) at magenta.main.Main.<init>(Main.java:20) at magenta.main.Main.main(Main.java:39)
    I have to say that in phpmyadmin, from GoDaddy, the user appears to login to a different IP than that where the database is stored.
    It says somenthing like this:
    # Server: testdatabase11.database server.com (IP1 via TCP/IP)
    # User: testdatabase11@IP2
    Don't know if that may be the cause of my problem though.
    I emailed them some hours ago but still didn't get any answer.
    Any help will be highly appreciated!

    I have a similar problem, I have a paid GoDaddy hosting account, ssh is enabled, and I can access the database from a php script run at home so its not an internet issue... I can't figure out what the problem is, but the program is crashing when I get to the createStatement() command... Any ideas anyone?
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class sqltest extends Activity {
                    Connection conn=null;
              try {
                   // from http://help.godaddy.com/topic/319/article/262
                   conn = DriverManager.getConnection(
                                       "jdbc:mysql://profiles.db.1111111.hostedresource.com:3306/dbname",
                                       "dbname", "password");
              } catch (SQLException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
              try {
                   // Create a result set containing all data from mysql_all_table
                   Statement stmt = conn.createStatement();
                   ResultSet rs = stmt.executeQuery("SELECT * FROM *");
    }PS: I'm technically doing this in android, but I think the problem is pure java...

  • Problems Connecting to MySQL Database

    When I run this I get the following exception:
    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 sql.LoadDriver.main(LoadDriver.java:16)
    Here's the code:
    package sql;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    // Notice, do not import com.mysql.jdbc.*
    // or you will have problems!
    public class LoadDriver
        public static void main(String[] args)
            // actual URL edited out, but format preserved
            String url = "jdbc:mysql://ipaddress";
            String username = "";
            String password = "";
            try {
                // The newInstance() call is a work around for some
                // broken Java implementations
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                Connection conn = DriverManager.getConnection(url, username, password);
                // Do something with the Connection
            } catch (SQLException ex) {
                // handle any errors
                System.out.println("SQLException: " + ex.getMessage());
                System.out.println("SQLState: " + ex.getSQLState());
                System.out.println("VendorError: " + ex.getErrorCode());
            } catch (Exception ex) {
                 ex.printStackTrace();
    }What am I doing wrong? The library I am using is the JRE 1.5.0_06 System Library. I downloaded MyQql Connector/J and I have the com.mysql.jdbc.Driver class yet I never use it so it does not seem that I would have to import it. I think the trouble is that I need to import a new library... should I import MySQL Connector/J as a new library? Or is this not the problem at all?

    Ah okay, I did that. Now I get this exception when
    running the program (same code as above):
    SQLException: No suitable driver
    SQLState: 08001
    VendorError: 0
    Is the format of my URL incorrect, Yes.

  • Connection to MySql in linux with jdbc odbc

    I am trying to connect my Applet to a MySql database
    Here is the code :
    try
                             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        }catch(Exception excpt)     {
                             txtLastName.setText("ERROR");
                   try {
                        String URL = "jdbc:odbc:mycon";
                        Connection con = DriverManager.getConnection(URL,"francis","pass");
                        } catch (SQLException e1) {
                        txtLastName.setText("ERROR");
                        }"mycon"-> name of the system DSN to MySql in ODBCconfig
    THE Stack trace :
    at sun.jdbc.odbc.JdbcOdbcDriver.initialize(Unknown Source)
         at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
    Please Helppp !!
    Thanks in Advance,
    Cheers,
    Francis

    Hey Thanks for the quick Reply
    Well ,
    I have checked and "mycon" is the right name of the
    DSN on the ODBCConfig.On the client machine? Not the server where the applet comes from but on the machine where it runs.
    That is the only way ODBC/DSN will work.

Maybe you are looking for

  • My apple id account is using an email to send me messages that im not familiar with

    Hello, Im having difficulty with my security questions I can not remember the answers to them. The email for the request of the amswers is not my email address so I am not able to use my apple ID account. How can you help me.

  • Drill Down Error DET_LEVEL

    Hi, I am writing a macro to enable data entry only when drill-down on 2 characteristics say Customer and Material. ========================= IF - Disaggregation Check DET_LEVEL('9AMATNR')=1 AND DET_LEVEL('9ACUST')=1 Row : KeyFigure (Attributes)= ROW_

  • Where are the files I printed with Adobe CreatPDF Desktop printer?

    When printing any MS files with the Adobe CreatePDF Desktop Printer, I don't know in which folder I must go to get the files. Any idea? Tks. Nicolas. Error message : documents in waiting lines

  • How to make hdiutil create segmented images?

    The problem: I need to make an image of my data on a UFS formatted drive. The folder is 16 Gb. The image file size is limited to 4Gb. I need to make hdiutil make an image segmented into parts less than 4 Gb, but when I give option -segmentSize 4Gb I

  • Help! Download repeatedly crashes around 17Mb

    I tried downloading using Flashget, this doesn't work. Then I downloaded the Sun download program. I tried downloading five times now and every time when I reach 17Mb something fails, recovery starts at 16 again. Endlessly... What is going on??? Than