SHARE
TWEET

Untitled

a guest Jun 15th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  java dbfile -cp /home/brads/mysql-connector-java-5.1.13/class/
  2. java.sql.SQLException: No suitable driver found for jdbc:mysql://nyctelecomm.com:3306/test
  3.         at java.sql.DriverManager.getConnection(DriverManager.java:640)
  4.         at java.sql.DriverManager.getConnection(DriverManager.java:200)
  5.         at DB.dbConnect(dbfile.java:26)
  6.         at dbfile.main(dbfile.java:8)
  7. [root@beat-box038 brads]# java -cp /home/brads/mysql-connector-java-5.1.13/class dbfile
  8. Exception in thread "main" java.lang.NoClassDefFoundError: dbfile
  9. Caused by: java.lang.ClassNotFoundException: dbfile
  10.         at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
  11.         at java.security.AccessController.doPrivileged(Native Method)
  12.         at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
  13.         at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
  14.         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
  15.         at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
  16.         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
  17. Could not find the main class: dbfile. Program will exit.
  18. [root@beat-box038 brads]# java -cp /home/brads/mysql-connector-java-5.1.13/mysql-connector-java-5.1.13-bin.jar dbfile
  19. Exception in thread "main" java.lang.NoClassDefFoundError: dbfile
  20. Caused by: java.lang.ClassNotFoundException: dbfile
  21.         at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
  22.         at java.security.AccessController.doPrivileged(Native Method)
  23.         at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
  24.         at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
  25.         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
  26.         at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
  27.         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
  28. Could not find the main class: dbfile. Program will exit.
  29. [root@beat-box038 brads]# java -cp dbfile /home/brads/mysql-connector-java-5.1.13/mysql-connector-java-5.1.13-bin.jar
  30. Exception in thread "main" java.lang.NoClassDefFoundError: /home/brads/mysql-connector-java-5/1/13/mysql-connector-java-5/1/13-bin/jar
  31. Caused by: java.lang.ClassNotFoundException: .home.brads.mysql-connector-java-5.1.13.mysql-connector-java-5.1.13-bin.jar
  32.         at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
  33.         at java.security.AccessController.doPrivileged(Native Method)
  34.         at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
  35.         at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
  36.         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
  37.         at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
  38.         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
  39. Could not find the main class: /home/brads/mysql-connector-java-5.1.13/mysql-connector-java-5.1.13-bin.jar. Program will exit.
  40. [root@beat-box038 brads]# java dbfile -cp /home/brads/mysql-connector-java-5.1.13/mysql-connector-java-5.1.13-bin.jar
  41. java.sql.SQLException: No suitable driver found for jdbc:mysql://nyctelecomm.com:3306/test
  42.         at java.sql.DriverManager.getConnection(DriverManager.java:640)
  43.         at java.sql.DriverManager.getConnection(DriverManager.java:200)
  44.         at DB.dbConnect(dbfile.java:26)
  45.         at dbfile.main(dbfile.java:8)
  46.  
  47.  
  48.  
  49.  
  50. code:
  51. import com.mysql.jdbc.*;
  52. import java.sql.*;
  53.  
  54. public class dbfile
  55. {
  56.         public static void main(String[] args)
  57.         {
  58.                 DB db = new DB();
  59.                 Connection conn=db.dbConnect(
  60.                   "jdbc:mysql://blah.com:3306/test", "brads",
  61. "andreasd");
  62.         }
  63.  
  64. }
  65.  
  66. class DB
  67. {
  68.         public DB() {}
  69.  
  70.         public Connection dbConnect(String db_connect_string,
  71.           String db_userid, String db_password)
  72.         {
  73.                 try
  74.                 {
  75.  
  76. Class.forName("com.mysql.jdbc.Driver").newInstance();
  77.                         Connection conn = DriverManager.getConnection(
  78.                           db_connect_string, db_userid, db_password);
  79.  
  80.                         System.out.println("connected");
  81.                         return conn;
  82.  
  83.                 }
  84.                 catch (Exception e)
  85.                 {
  86.                         e.printStackTrace();
  87.                         return null;
  88.                 }
  89.         }
  90. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top