No suitable driver found for host

Discussion in 'Plugin Development' started by Pezah, Jan 3, 2014.

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

    Pezah

    Could someone please tell me why im getting this error;
    http://puu.sh/68SbL.png

    Code;
    Code:
    package me.loogeh.Hype.SQL;
     
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
     
    import org.bukkit.entity.Player;
     
    public class MySQL {
       
        static Connection SQL;
        public static String pass = "my pass";
        public static String host = "my host";
        public static String user = "my user";
        public static String db = "my datbabase";
        static String url = "jdbc:mysql://myHost:3306/myDatabase";
     
     
        public Connection testDBConnection() {
            try {
               
                Connection con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + 3306 + "/" + db, user, pass);//url, user, pass);
                System.out.println("Hype SQL: Test connection success");
                //con.close();
            } catch (SQLException e) {
                System.out.println("Hype SQL: Test connection failed");
                //return false;
            }
            return con;
        }
     
        public static void setupMySql() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
            try {
                Class.forName("com.mysql.jdbc.Driver");
                System.out.println("Connecting to database...");
            } catch (final Exception e) {//catch (ClassNotFoundException e) {
                System.out.println("Hype SQL: Could not setup up MySQL");
                e.printStackTrace();
            }
            SQL = MySQL.getSQLConnection();
        }
     
        public static Connection getSQLConnection() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
            try {
                return DriverManager.getConnection(host, user, pass);
            } catch (SQLException e) {
                System.out.println("Hype SQL: Unable to connect");
                e.printStackTrace();
            }
            return null;
        }
     
        public static String SQLFormat(String data) {
            return "'" + data + "'";
        }
     
        public static void doUpdate(String statement){
            Statement st;
            try {
                st = SQL.createStatement();
            }
            catch (SQLException e) {
                e.printStackTrace();
                return;
            }
            try {
                st.executeUpdate(statement);
            } catch (SQLException e) {
                e.printStackTrace();
                System.out.println("Hype SQL: Could not execute Statement " + statement);
                return;
            }
        }
     
        public static ResultSet doQuery(String query){
            Statement st;
            try {
                st = SQL.createStatement();
            }
            catch (SQLException e) {
                e.printStackTrace();
                return null;
            }
            try {
                ResultSet rs = st.executeQuery(query);
                return rs;
            } catch (SQLException e) {
                e.printStackTrace();
                System.out.println("Hype SQL: Could not execute query " + query);
                return null;
            }
        }
     
        public static String f(String string) {
            return "'" + string + "'";
        }
     
        public static String fc(String string) {
            return "'" + string + "',";
        }
    }
    
     
  2. Offline

    RawCode

    Provide full log as text.
     
  3. Offline

    Pezah

    Fixed, my friend had his craftbukkit in at the same time as me through saros eclipse.
     
Thread Status:
Not open for further replies.

Share This Page