Home > Back-end >  When using eclipse mysql5 link link
When using eclipse mysql5 link link

Time:10-07

When using eclipse links database, abnormal, mysql service opened and package also import, is an operation error!
Import the Java. SQL. Connection;
Import the Java. SQL. DriverManager;
Import the Java. SQL. SQLException;
Import Java, SQL Statement;

Public class ss {
Private static final String URL="JDBC: mysql://localhost: 3306/test".
Private static final String USERNAME="root";
Private static final String PWD="root";

Public static void the update () {//to add authorization
Connection connection=null;
The Statement STMT=null;
Try {
//a. import drive, load specific drivers class
Class.forName("com.mysql.jdbc.Driver");//load specific drivers class
//b. establish connection with database
The connection=DriverManager. GetConnection (URL, USERNAME, PWD);
//c. send SQL execution (increase, deletion)
STMT=connection. CreateStatement ();
//String SQL="insert into student values (1, 'zs, 23,' s1 ')";
//String SQL="update student set STUNAME='ls' where stuno=1";
String SQL="delete from student where stuno=1";
//execute SQL
Int count=STMT. ExecuteUpdate (SQL);//the return value said to add a few data deletion
//d. the results
If (count & gt; 0 {
System. Out.println (" operation success!" );
}
} the catch (a ClassNotFoundException e) {
e.printStackTrace();
} the catch (SQLException e) {
e.printStackTrace();
} the catch (Exception e) {
e.printStackTrace();
}
The finally {
Try {
If (STMT!=null) STMT. Close ();//object. Methods
If (connection!=null) connection. The close ();
} the catch (SQLException e) {
e.printStackTrace();
}
}
}

Public static void main (String [] args) {
The update ();
}
}
The following under the eclipse error message:
The Exception in the thread "main" Java. Lang. NoClassDefFoundError: org/apache/juli/logging/LogFactory
The at org. Apache. Catalina. Util. LifecycleBase. & lt; Clinit> (LifecycleBase. Java: 39)
Under Caused by: Java. Lang. ClassNotFoundException: org. Apache. Juli. Logging. LogFactory
The at java.net.URLClassLoader.findClass URLClassLoader. Java: (381)
The at Java. Lang. This. LoadClass (424). This Java:
At sun. Misc. The Launcher $AppClassLoader. LoadClass (335). The Launcher Java:
The at Java. Lang. This. LoadClass (357). This Java:
. 1 more
  • Related