JDBC, MySQL and the rudeness of SQLExceptions

Hi there
I'm having an annoying problem (no, really?).
I've got a MySQL database running on a nice little Red Hat Linux server. It works just fine, and I can access it remotely from my windows desktop. So I'm trying to write a little client app.
I'm using Windows XP with Java2 v1.4.01. For my JDBC drivers I'm using Connector/J (formerly mm.mysql). The connector/J jar is in jre\lib\ext. I have also unpacked it to C:\Java\Connector and linked directly to the jar in my CLASSPATH environment variable.
So everything sounds right so far, yeah?
Trouble is, every time I try to connect I get a rude "No Suitable Driver" error. I've searched extensively for material about this problem, but no solution I've tried seems to work. Any comments, suggestions etc will be appreciated.
The test code is quoted below:
import java.sql.*;
public class MySQLClient{
private boolean connected;
private Connection conn;
public MySQLClient(){
     connected = false;
public boolean Connect(String userName, String userPwd){
try {
     

Hmmmm code was cut off. Here it is again.
import java.sql.*;
public class MySQLClient{
private boolean connected;
private Connection conn;
public MySQLClient(){
     connected = false;
public boolean Connect(String userName, String userPwd){
try {
     Class.forName("com.mysql.jdbc.Driver").newInstance();
     conn = DriverManager.getConnection(
"jdbc:mysql:190.100.7.1:3306", userName, userPwd);
     connected = true;
     System.out.println("Connect OK!");     
     } catch (java.lang.ClassNotFoundException e){
System.err.println("Can't find the freakin' driver");
     System.err.println(e.getMessage());
     } catch (java.lang.InstantiationException e){
     System.err.println("WTF???");
     System.err.println(e.getMessage());
     } catch (java.lang.IllegalAccessException e){
System.err.println("Illegal access");
     System.err.println(e.getMessage());
%

Similar Messages

  • Mm.mysql JDBC Driver and the WHERE clause

    Anybody has succesfully performed a MySQL/JDBC query in a JSP application using more than one variable in the WHERE clause?
    It works fine when I run queries with one fixed value assigned to a column and one variable assigned to the other column in the WHERE clause; but when I do it with more than one variable in the WHERE clause, it screws up throwing an error.
    I wonder if it is a code error, a syntax error or if it is something tricky about the mm.mysql JDBC Driver. Following is a section of the code and the error. The variables are s_description and s_status. I read some examples in a book but they use SQL Server. Thank you in advance for any information.
    CODE:
    <% String sqlStatement = "" ; %>
    <% String s_description = "Mexican Style Rice" ; %>
    <% String s_status = "available" ; %>
    <% java.sql.Statement stmt = con.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_UPDATABLE); %>
    <% java.sql.ResultSet rs ; %>
    <% sqlStatement = "SELECT code, description, status FROM products WHERE products.description =" + s_description + " AND products.status =" + s_status + ";" ;%>
    <% rs = stmt.executeQuery(sqlStatement); %>
    <% rs.beforeFirst(); %>
    <% while (rs.next()) { %>
    <% rs.updateString(3, "sold"); %>
    <% rs.updateRow(); %>
    <% }%>
    <% rs.close(); %>
    This is the ERROR it throws
    java.sql.SQLException: Column not found: Unknown column 'available' in 'where clause'
         at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java:497)
         at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(MysqlIO.java:550)
         at org.gjt.mm.mysql.MysqlIO.sqlQuery(MysqlIO.java:635)
         at org.gjt.mm.mysql.Connection.execSQL(Connection.java:882)
         at org.gjt.mm.mysql.Connection.execSQL(Connection.java:815)
         at org.gjt.mm.mysql.Statement.executeQuery(Statement.java:169)
         at org.gjt.mm.mysql.jdbc2.Statement.executeQuery(Statement.java:78)
         at pagecompile._GetFood_xjsp._jspService(_GetFood_xjsp.java:45)
         at com.newatlanta.servletexec.JSP10HttpJspPage.service(JSP10HttpJspPage.java:41)
         at com.newatlanta.servletexec.JSP10Servlet.service(JSP10Servlet.java:779)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.newatlanta.servletexec.ServletExec.CallServletService(ServletExec.java:1679)
         at com.newatlanta.servletexec.ServletExec.processServletRequest(ServletExec.java:1654)
         at com.newatlanta.servletexec.ServletExec.processServletAlias(ServletExec.java:1602)
         at com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1343)
         at com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1113)

    I think perhaps this sentence has problems:
    <% sqlStatement = "SELECT code, description, status FROM products WHERE products.description =" + s_description + " AND products.status =" + s_status + ";" ;%>
    You can
    <% sqlStatement = "SELECT code, description, status FROM products WHERE products.description ='" + s_description + "' AND products.status = '" + s_status + "'" ;%>
    You perhaps ignore the ���� when using String variable s_description and s_status.
    Hope this will help you. Good lucky!

  • Oracle JDBC driver and the object types cache

    Hi there,
    Oracle JDBC Developer's Guide and Reference says (version 11gR1):
    Oracle JDBC drivers cache array and structure descriptors. This provides enormous performance benefits. However, it means that if you change the underlying type definition of a structure type in the database, the cached descriptor for that structure type will become stale and your application will receive a SQLException exception.http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/oraoot.htm#g1104293
    That is the problem we are having here... We have web services deployed to WebLogic server that use custom object types. Every time we have to change an object type definition the web services stop working (the error ORA-00902: invalid datatype is raised) and the only solution is to restart the JDBC data source which is quite disruptive to the development process.
    Is there a workaround to disable that "feature"?
    Thanks
    Luis

    Luis Cabral wrote:
    jschell wrote:
    Although if you are changing the object structure then the code to deal with it must change as well. So, especially in developement, why is restarting a problem?It is not that restarting per se is a problem. Here us developers do not have the required privileges to restart the JDBC pool and we have to ask the DBA to do it, and sometimes he is not immediately available. It is not a big thing but this can impact the development process.Your development process is hideously flawed then.
    The pool exists in the JEE server. And from your first post it seems that you have permission to restart that but not to access the management console. It is ridiculous to have access the the former and not the later.
    Not to mention that you should have your own JEE instance to develop on. Actually it is weird to me that a DBA would even be touching a JEE server. The competent ones I know don't even know how to do that. They know the database not the application servers.
    >
    In addition, having to restart a whole JDBC pool just because you changed a database object definition does not seem very flexible to me. Such issue does not exist in other connection types, for instance in OCI connections, that is why I thought there should be an option to turn it off if required.
    Well specifically you have to restart the pool because you were USING the object that changed.
    And I am rather certain that you can turn off the pool entirely.
    Even in production, I reckon that this may have a negative impact. For instance, say that you need to deploy a hot fix for a bug in one application that involves the re-creation of one single object type. This means that the whole JDBC pool, which may be used by other applications, may have to be shut down just because of that single object.Good point.
    I suggest you stop using complex objects in Oracle. I suspect that would eliminate the problem completely.

  • I downloaded mySQL and mySQL driver NOW  WHAT ?

    I downloaded the mySQL and the mySQL driver. What do I do now ?
    I saw a book "mySQL and PHP for Dummies" . What is PHP ?
    Can you give me direction ?
    (without the "go read the archives" type of non-helpful help ?)
    Thank you in advance
    Stan

    If it's PHP and MySQL you're interested in, why are you posting to a Java forum?
    PHP is a Web scripting language:
    http://www.php.net/
    If you want to use MySQL with Java, you'll have to learn enough about SQL and relational databases to be able to get into MySQL, create some tables and users, and add some data. Then you'll use the MySQL JDBC driver to let your Java app access those database tables and do CRUD operations on them (Create/Read/Update/Delete).
    There's a JDBC tutorial under the Tutorials link to the left on this page.
    Here's a Java app that will let you run any valid SQL statement you wish against any database:
    import java.sql.*;
    import java.util.*;
    public class DataConnection
        public static final String DEFAULT_DRIVER   = "sun.jdbc.odbc.JdbcOdbcDriver";
        public static final String DEFAULT_URL      = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\Edu\\Java\\Forum\\DataConnection.mdb";
        public static final String DEFAULT_USERNAME = "admin";
        public static final String DEFAULT_PASSWORD = "";
        /** Database connection */
        private Connection connection;
         * Driver for the DataConnection
         * @param command line arguments
         * <ol start='0'>
         * <li>SQL query string</li>
         * <li>JDBC driver class</li>
         * <li>database URL</li>
         * <li>username</li>
         * <li>password</li>
         * </ol>
        public static void main(String [] args)
            DataConnection db = null;
            try
                if (args.length > 0)
                    String sql      = args[0];
                    String driver   = ((args.length > 1) ? args[1] : DEFAULT_DRIVER);
                    String url      = ((args.length > 2) ? args[2] : DEFAULT_URL);
                    String username = ((args.length > 3) ? args[3] : DEFAULT_USERNAME);
                    String password = ((args.length > 4) ? args[4] : DEFAULT_PASSWORD);
                    db = new DataConnection(driver, url, username, password);
                    Object result = db.executeSQL(sql);
                    System.out.println(result);
                else
                    System.out.println("Usage: db.DataConnection <sql> <driver> <url> <username> <password>");
            catch (SQLException e)
                System.err.println("SQL error: " + e.getErrorCode());
                System.err.println("SQL state: " + e.getSQLState());
                e.printStackTrace(System.err);
            catch (Exception e)
                e.printStackTrace(System.err);
            finally
                if (db != null)
                    db.close();
                db = null;
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection() throws SQLException,ClassNotFoundException
            this(DEFAULT_DRIVER, DEFAULT_URL, DEFAULT_USERNAME, DEFAULT_PASSWORD);
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection(final String driver,
                              final String url,
                              final String username,
                              final String password)
            throws SQLException,ClassNotFoundException
            Class.forName(driver);
            this.connection = DriverManager.getConnection(url, username, password);
         * Clean up the connection
        public void close()
            try
                this.connection.close();
            catch (Exception e)
                ; // do nothing; you've done your best
         * Execute ANY SQL statement
         * @param SQL statement to execute
         * @returns list of row values if a ResultSet is returned,
         * OR an altered row count object if not
         * @throws SQLException if the query fails
        public Object executeSQL(final String sql) throws SQLException
            Object returnValue      = null;
            Statement statement     = this.connection.createStatement();
            boolean hasResultSet    = statement.execute(sql);
            if (hasResultSet)
                ResultSet rs            = statement.getResultSet();
                ResultSetMetaData meta  = rs.getMetaData();
                int numColumns          = meta.getColumnCount();
                List rows               = new ArrayList();
                while (rs.next())
                    Map thisRow = new LinkedHashMap();
                    for (int i = 1; i <= numColumns; ++i)
                        String columnName   = meta.getColumnName(i);
                        Object value        = rs.getObject(columnName);
                        thisRow.put(columnName, value);
                    rows.add(thisRow);
                rs.close();
                statement.close();
                returnValue = rows;
            else
                int updateCount = statement.getUpdateCount();
                returnValue     = new Integer(updateCount);
            return returnValue;
    }Maybe it'll help get you started with Java and JDBC. You're on your own with PHP. - MOD

  • Installed PHP & MySQL, and now I have file permission errors.

    Hi Everyone
    I recently made a switch from using MAMP to making a separate installation of PHP, MySQL and Rails. I used the first tutorial for Rails + MySQL, and the second one for PHP;
    http://hivelogic.com/narrative/articles/ruby-rails-mongrel-mysql-osx
    http://www.entropy.ch/software/MacOSx/mysql/
    Unfortunately, I now receive errors when trying to install activeCollab through it's own PHP install script, and WordPress won't let me import xml backups into a locally installed WordPress. This must mean that I don't have full Read/Write access to my 'Sites' directory (this is set as my default htdocs in the Apache httpd.conf). I haven't noticed any problems with Rails - so far it's only been PHP based CMS's which have thrown up the permission errors.
    I've checked the file permissions on my 'Sites' folder - I'm the only user on the machine, and my account has full Read/Write access to the folder. However, I've noticed that there is also the option to choose 'Group' access, for which my account is again selected and given Read/Write access.
    Then there is 'Others' category, and this has 'Read only' access. Is there an option in there which I need to select and give Read/Write permissions to? mysql, php ?
    Or, is there a MySQL/PHP/Apache config file somewhere, within which I need to give global read/write permissions?
    I didn't have this problem when I was served up local sites from MAMP - and I also configured MAMP to use the 'Sites' folder as it's default htdocs folder. I get the impression that because MAMP was installed as an 'Application', that it automatically inherited my user permissions - maybe PHP and MySQL don't inherit my user account permissions because they are services?...
    I've come very far with getting everything installed to work with the OS X bundled Apache server (which I believe is 1.3 - I certainly haven't updated it) so I'd love to get everything finally configured - therefore, any help with this is very, very much appreciated!
    MacBook Pro 2.4Ghz    

    You'll probably get a better response at the Server Products or Networking & Web http://discussions.apple.com/forum.jspa?forumID=733 forums.

  • MySQL and JDBC Classpath errors

    I am new to Java and installed MySql and also installed mysql-connectorJ driver. I can compile the code below, but when I go to run it, I get "Exception in thread "main" java.lang.NoClassDefFoundError: JDBCDemo/class" error. I can't figure out what I am doing wrong.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class JDBCDemo {
         public static void main(String[] args) {
              try{  
    Class.forName("com.mysql.jdbc.Driver");
              catch (Exception e)
                   e.printStackTrace();
    I have a the following environment variable called MySQL_Driver located at "C:\Program Files\Java\jdk1.5.0_06\lib".
    Path = "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared;%JAVA_HOME%;%JAVA_HOME%\lib;%JAVA_VM%\bin;%JAVA_VM%\lib;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\QuickTime\QTSystem\;%MySQL_Driver%"

    What is your CLASSPATH set to as you need to make sure that the driver is in the path as well as the directory/jar where the JDBCDemo app lives.
    Try explictly specifying everything via the -classpath option on your java command line

  • The mysteries of JDBC, JNDI, and Tomcat 5.5.4

    Like thousands beforefore, I can't get connection pooling to work in Tomcat. I followed all the steps:
    - put jar file for MySQL JDBC driver in TOMCAT_HOME/common/lib
    - put the Jakarta Commons libs in the same location
    - put resource declaration in META-INF/context.xml, per the Tomcat 5.5 docs like so:
    <Context docbase="C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\commutercorps"
        path="\commutercorps" >
        <Resource name="jdbc/commutercorpsds"
            auth="Container"
            type="javax.sql.DataSource"
            maxActive="100"
            maxIdle="30"
            maxWait="10000"
            username="myusername"
            password="mypassword"
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/commuter_corps_signup"/>
    </Context>- added resource ref in web.xml
        <resource-ref>
            <description>DB Connection</description>
            <res-ref-name>jdbc/commutercorpsds</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
        </resource-ref>I also double checked my connection URL and found that it does work fine when do this in my Java code:
    Class.forName("com.mysql.jdbc.Driver");
    Connection con =
        DriverManager.getConnection
        ("jdbc:mysql://localhost:3306/commuter_corps_signup", "...", "...");When I try to use Tomcat 5.5.4, JNDI like this...
                    try
                        InitialContext initialContext = new InitialContext();
                        DataSource dataSource =
                                (DataSource) initialContext.lookup
                                ("java:comp/env/jdbc/commutercorpsds");
                        Connection con = dataSource.getConnection();
                        Statement stmt = con.createStatement();
                        stmt.executeUpdate(SQLMaker.getInsert(request,
                                request.getParameter("table")));
                        con.close();
                        stmt.close();
                    } catch (NamingException e)
                        System.out.println(e.getMessage());
                        e.printStackTrace();
                    }...I get...
    Cannot create JDBC driver of class '' for connect URL 'null'
    Caused by: java.sql.SQLException: No suitable driver
    Any help would be greatly appreciated.
    Thanks,
    E

    I used to get the message
    Cannot create JDBC driver of class '' for
    connect URL 'null'
    No suitable driverError.
    I was running, jakarta-tomcat-5.0.14.exe on windows.
    I had it installed on a path without spaces
    d:\tomcat5\Good.
    I wanted to use Hibernate. So i used, extensiontools.What's that?
    First create a env var: HIBERNATE_HOME pointing to
    the hibernate extracted dir.No need for this.
    Modify setenv.bat to correct %CP% for
    commons-logging, commons-collection and anything
    else: the version string at the end of the jar
    changes.Wrong. You shouldn't be doing this.
    Then run ddl2hbm, straightforward, fill info in all
    tabs and hit generate. Will show some error message,
    but still creates xmls.I don't see what any of this has to do with Tomcat deployment.
    Then run hbm2java, and hand over each xml file as
    parameter. Creates some java files in generated dir.
    Modify the toString method to something simpler and
    remove the import for apache class.All great, but still has nothing to do with Tomcat deployment.
    move them over to webapp classes.You should create a WAR file or a separate context directory for your application under /webapps. If you're doing anything else, it's wrong.
    Create JNDI in sever.xml as mentioned.Nope. Shouldn't be editing server.xml. Put that stuff in an application-specific context.xml, which goes in the META-INF of your WAR file.
    Create reference in web.xml as mentioned.Good.
    Goto conf/catalina/localhost/<webappname>.xmlNo need for this. Don't know what you're doing here.
    add the line
    <ResourceLink name="jdbc/Oracle"
    type="javax.sql.DataSource" global="jdbc/Oracle"/>
    replace Oracle with your datasource name.
    and i got me workingMight be working, but it's not really correct.
    %

  • Mysql, JDBC, Linux and Access Denied

    I have just installed a MySQL Connctor/J 2.0.14 (JDBC) to be able to connect to a MYSQL-database on a Linux-server from a java-program on the same server. But I keep on getting an access-right-error. I would be very thankfull if someone could help me.
    From the linux-shell I can connect to the database with mysql:
    [root@dat test]# mysql -u speciale -p specialetestDB
    But when I try to connect from the Java-program I recieve the following error:
    [root@dat test]# java TestDB
    SQL-fejl: Invalid authorization specification: Access denied for user: 'speciale@dat' (Using password: YES)
    The program Is very simple:
    import java.sql.*;
    public class TestDB {
    public static void main(String[] args) {
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection connection = DriverManager.getConnection(
    "jdbc:mysql://localhost/specialetestDB?user=speciale&password=x");
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(
    "Select Vnavn from VidensElement");
    while (resultSet.next())
    System.out.println(resultSet.getString("Vnavn"));
    statement.close();
    connection.close();
    catch (SQLException sqlException) {
    System.out.println("SQL-fejl: " + sqlException.getMessage());
    catch (ClassNotFoundException classNotFoundException) {
    System.out.println("Driver ikke fundet: " +
    classNotFoundException.getMessage());
    catch (Exception instantiationException) {
    System.out.println("Driver kan ikke instantieres: " +
    instantiationException.getMessage());
    Sanne

    the password you have listed as what you use fromthe
    shell vs. what you have in yoour code are not the
    same. they need to be the same.
    other than that make sure you user account in mysqlis
    set up to accept connections from wherever you needit
    to. Thanks,
    The passwords are the same - I just didn't show it in
    the copied text. Actually the shell-dialog is:
    From the linux-shell I can connect to the database
    with mysql:
    [root@dat test]# mysql -u speciale -p specialetestDB
    password: x
    sorry my fault, but it probably was worth checking
    But what you said about my user accounts might be the
    problem In the mysql.user tabel I have 3 instances of
    the "speciale" user, each with a different host: "%",
    "dat" and "localhost".
    Is that what you ment?
    yes. it is possible that the passwords are not the same. so the password for speciale from localhost is not the same as from % or dat. why don't you delete the dat and localhost ones and just leave the % one.

  • Need help setting up JDBC with mySQL and Netbeans

    I've successfully got mySQL up and running and created a few simple test databases. I've been following the instructions on this website (http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1 ) to get JDBC working but have had little luck.
    I've downloaded JDBC from mySQL website, extracted the mysql-connector-java-3.1.13-bin.jar file and changed the class path to :
    C:\Program Files\Java\jre1.5.0_06\lib\ext\mysql-connector-java-3.1.13-bin
    which is where I placed the .jar file.
    I then used the following code provided on stardeveloper.com to test a connection with the test database.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class JdbcExample2 {
      public static void main(String args[]) {
        Connection con = null;
        try {
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          con = DriverManager.getConnection("jdbc:mysql:///test",
            "root", "secret");
          if(!con.isClosed())
            System.out.println("Successfully connected to " +
              "MySQL server using TCP/IP...");
        } catch(Exception e) {
          System.err.println("Exception: " + e.getMessage());
        } finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    }It compiles but when run I get the error message :
    java.lang.NoClassDefFoundError: testdatabase/JdbcExample2
    Exception in thread "main"I assume this means that my classpath isn't setup correctly but I have no idea what's up and how to correct it.
    Can someone PLEASE tell me how to setup jdbc and what I've done wrong.
    Thanks in advance :)

    Thanks for your reply. I've made some progress but I'm still having problems.
    In mySQL I created a new user called uraknai with password n0121429 and granted them access to a test database I created called pet.
    Then, in netbeans, I clicked the Runtime tab, clicked Databases and rightclicked Drivers and clicked Add Driver. I then added the driver mysql-connector-java-3.1.13-bin.jar. I then right clicked the newly added driver and selected the connect using option. I filled in the appropriate boxes clicked ok and it connected successfully.
    Then, under the project tab, I right clicked the project name, clicked properties then clicked Libraries and added the .jar file mysql-connector-java-3.1.13-bin.jar
    I then ran the following code to test the connection to the database:
    import java.sql.*;
    public class ConnectionTest {
        public ConnectionTest() {
        public static void main(String[] args)
            System.out.println("BEGIN CONNECTION TEST");
            Connection conn = null;
            try
                   String userName = "uraknai";
                   String password = "n0121429";
                   String url = "jdbc:mysql://localhost/pet";
                   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 */ }
    }and get the message:
    java.lang.NoClassDefFoundError: math/ConnectionTest
    Exception in thread "main"
    Java Result: 1when I run the code.
    Can someone explin what I've done wrong and how to fix the problem.
    Cheers.

  • "jdbc:mysql:///test" - "jdbc:mysql:test" what is the difference

    "jdbc:mysql:///test" -> "jdbc:mysql:test" what is the difference:
    I used both of them in my url but only "jdbc:mysql:///test" worked only
    what is the difference what /// means?

    JDBC URLs have the format
    jdbc:<subprotocol>://<data source identifier>
    jdbc indicates a JDBC data source. subprotocol identifies which JDBC Driver to use.
    For com.mysql.jdbc.Driver and localhost server, database name as 'test':
    it's jdbc:mysql://localhost/test
    or jdbc:mysql://127.0.0.1:3306/test
    you would select another server and database name.
    For sun.jdbc.odbc.JdbcOdbcDriver with MS Access or SQLServer database, it's jdbc:odbc:DSNname
    HTH

  • JDBC MYSQL localhost vs. over the internet

    I am new to java so please take it easy on me. I have a little bit of a crisis here and want to make sure I understand what it is that I am trying to accomplish.
    I have a Java application that I want people to run from their machine that access my web server over the internet and connects to my MYSQL database. It uses webstart to download application to their machine where they run it locally. Here is how I have this setup. Is this not a standard practice? Or should I have used a different Java technology to have them run the application directly from my server using localhost instead of mywebsite?
    So, am I using java in a practical way using mywebsite.com:3306 and the user running it locally on their machine. Or do I have to set this up so they run in on my server using localhost?
    try
                   String userName = "testuser";
                   String password = "testpass";
                   String url = "jdbc:mysql://mywebsite.com:3306/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");
               }Edited by: crusherdestroyer on Jan 20, 2010 10:28 AM
    Edited by: crusherdestroyer on Jan 20, 2010 10:29 AM

    Good evening, CD.
    As the others have said, you should not have your SQL server exposed to the public. If you use ACLs or similar and allow only trusted hosts to access your MySQL server, you should be fine to continue as-is (Java client connecting to TCP port 3306 of your server if I understand your explanation correctly.) If you want to convert your simple application to a server-side app, you could also use something like procrun if your server is running Windows or jsvc for UNIX/Linux. This will enable you to run your app as a service/daemon and you could configure it to listen on an arbitrary port for incoming connections and use the app as an intermediary for interfacing connecting clients with your MySQL database. This is just another idea opposed to installing and configuring Tomcat, Jetty, or the like and possibly a webserver in front of that.
    Regards,
    Lloyd Dilley

  • MySQL and JDBC

    Hey all. I looked around and saw many similar messages like mine will be, but I could not fix it.
    I have an account over on some webhost and I want to connect to my Database over there. However, I keep getting:
    Exception: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection timed out: connectHere is the code:
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        String connectionURL = "jdbc:mysql://www.mydomain.com/mydatabase";
        java.sql.Connection connection = DriverManager.getConnection(connectionURL, "myuser", "mypass");
        java.sql.Statement statement = connection.createStatement();
        java.sql.ResultSet rs = statement.executeQuery("Select * from mytable");Thanks for the help, all!

    Hi,
    Can you provide the port number where mySQL is runnuing in your "connctionURL" like "jdbc:mysql://www.mydomain.com:3306/mydatabase";
    default port is 3306, check your luck.
    Class.forName("com.mysql.jdbc.Driver").newInstance(); String >connectionURL = "jdbc:mysql://www.mydomain.com/mydatabase"; >java.sql.Connection connection = DriverManager.getConnection(connectionURL, "myuser", "mypass"); java.sql.Statement statement = >connection.createStatement(); java.sql.ResultSet rs = >statement.executeQuery("Select * from mytable");Raju

  • Update of MySQL and SQL Server JDBC Driver does not work in 1.2.1

    Hi,
    always after the update process is started i got the MySQL and SQL Server JDBC driver
    update notification.
    But all the time after i install the update i got the notification again but no errormessage
    that the update was maybe not successful ???
    Frank

    Ok
    then my subject was false
    i always try to update the extensions and now i can see that they are updated on the filesystem but the IDE does not recognize them as updated
    ....\sqldeveloper\sqldeveloper\extensions\oracle.sqldeveloper.thirdparty.drivers.mysql
    is available and new after the update process
    and under
    ...\sqldeveloper\sqldeveloper\tmp\update\oracle.sqldeveloper.thirdparty.drivers.mysql.5239.zip
    the downloaded zip file is also available.
    In the update window the message is that the extension with version 5206 is available
    Maybe that is the problem cause the downloaded files are version 11.1.1.5239
    if you look at the bundle.xml file inside the META-INF directory
    Frank

  • Jdbc mysql "select ... for update" and isolation level...

    Dear, I am now writing an application, in which some worker threads will get a waiting job from database (mysql) and perform the processing.
    To avoid workers getting the same job id, I have studied the topics about locks, isolation level, and something like "select ... for update".
    The storage engine being used is innoDB. Actually the problem seems solved after using "select ... for update" to get the id, but I am just curious that do I also need to care about the isolation level. It is because when I do some experiments by setting the isolation level to serializable, but NOT using "SELECT ... FOR UPDATE" (just simple select), exception something like "deadlock found and try to restart transaction" occurs. Is there any relationship between these two things? Any comments are welcome!! Thanks!!!

    ashipj wrote:
    can u plz provide me with the code (connection string). Am new to Mysql.
    And also the driver u are using.
    Thank youDon't hijack other's topics. Kindly start your own. Don't do that before you read the [Sun JDBC tutorial|http://java.sun.com/docs/books/tutorial/jdbc/index.html] and the [MySQL JDBC documentation|http://dev.mysql.com/doc/refman/5.0/en/connector-j.html].

  • What is the difference between mysql and mysqli

    hello can any one tell me What is the difference between mysql and mysqli ? i googled but i cant find any
    Edited by: 994030 on Mar 14, 2013 3:43 PM

    Yes. they are the same.

Maybe you are looking for

  • Fonts being deleted in windows 8.1! Is an update the cause?

    Hi, After a reboot nearly all fonts are missing in the fonts folder. It has much influence to the running programs, they sometimes don't work at all! When I reinstall the fonts, they seem to still be there, but the same time they are missing. And aft

  • Codesign tutorial - step by step (I can get it to work)

    Trying to upload an ipa to the app store and it said it wasn't signed. The exact vague error is: Application failed codesign verification. The signature was invalid, contains disallowed entitlements, or it was not signed with an iPhone Distribution C

  • To filter records using XSLT mapping

    Hi all, I am using XSLT mapping in my scenario. I have below structure. <Node>     <emp_id>123<emp_id>     <begin_date>dd/mm/yyyy<begin_date/>     <end_date>dd/mm/yyyy<end_date/>     <check_date>dd/mm/yyyy<check_date/> <Node/> I want to filter out th

  • Whlile connecting iPad to computer, battery is not getting charged

    What settings to be made so that when I will connect my iPad to computer, my Pad's battery should get recharge. While connecting iPhone, it is getting recharged but not the Pad.

  • 100% CPU load but no clue in thread dump, EP. Win a bottle of champagne...

    Hi, We are suddenly facing 100% CPU load in our EP cluster (5 x 8-way Xeon multiprocessor machines). We have a serious performance problem that is burning a lot of our time and causes a lot of stress for over 3 weeks now. We have taken tens of thread