The best way to do MySQL support?

Discussion in 'Plugin Development' started by nicatronTg, Mar 5, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    nicatronTg

    I'm writing a plugin that registers users on a website, so they can login and change settings and upload files, but the major bottleneck has been getting MySQL working. I've tried just about everything I can think of, and each plugin I've looked at does it differently, so what's the best way? I can't set classpath on the box I'm deploying to, so I can't reliably make sure that the MySQL driver exists for JDBC. Is there an easier way to define the location of a connector, or a better way to connect than JDBC?
     
  2. Offline

    Archelaus

    Manifest file would work.
     
  3. Offline

    nicatronTg

    Still having troubles getting it to work.

    Jar
    --META-INF
    ---MANIFEST.MF
    Code:
    Manifest-Version: 1.0
    
    Class-Path: ../lib/mysqlcon.jar
    And the code calling it is:
    Code:
    try
            {
                Class.forName("com.mysql.jdbc.Driver");
                Connection conn = DriverManager.getConnection( database, username, password);
                Statement stat = conn.createStatement();
                String _query = query;
                ResultSet result = stat.executeQuery( _query );
                while( result.next() )
                {
                        System.out.println( "Name: \t" + result.getString("username") );
                        System.out.println( "\nPassword: \t" + result.getString("password") );
                }
                conn.close();
            }
            catch( SQLException e )
            {
                e.printStackTrace();
            }
            catch (ClassNotFoundException e) {e.printStackTrace();}
    I'm getting a ClassNotFoundException on com.mysql.jdbc.Driver, so I'm not sure what the deal is. The file exists, something else isn't working though.
    --- merged: Mar 6, 2011 12:39 AM ---
    Fixed, if there isn't a newline after the end classpath, it doesn't get defined properly.
     
  4. Offline

    Raider

    honestly the easiest way to do this is put the JDBC driver in your jre lib/ext folder.
     
  5. Offline

    Gandalf

Thread Status:
Not open for further replies.

Share This Page