java连接mySQL数据库,出问题,代码我给出来了,错误看不懂,给出来了,求大神 10
packageBotherDatebase;importjava.sql.*;//增删改操作publicclassJdbcDemo{//连接数据库地址publicfina...
package BotherDatebase;
import java.sql.*;
//增删改操作
public class JdbcDemo {
//连接数据库地址
public final static String URL = "jdbc:mysql://localhost:3306/test";
public final static String USERNAME = "root";
public final static String PASSWORD = "password";
//插入操作
public static void insert(){
//1加载驱动
try {
Class.forName("com.mysql.jdbc.Driver");
//2获取数据库连接
Connection conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
//3构造SQL语句
String sql = "insert into person(name,age,description)value('小白',18,'一个人')";
//4构造一个statement实例(用来发送 语句的载体)
Statement state = conn.createStatement();
//5执行语句
state.executeUpdate(sql);
//6关闭连接,释放资源
state.close();
conn.close();
System.out.println("success");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
insert();
}
}
这里是错误,看不懂,不知道错在哪里
Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:260)
at BotherDatebase.JdbcDemo.insert(JdbcDemo.java:15)
at BotherDatebase.JdbcDemo.main(JdbcDemo.java:39)
Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.Signature
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more 展开
import java.sql.*;
//增删改操作
public class JdbcDemo {
//连接数据库地址
public final static String URL = "jdbc:mysql://localhost:3306/test";
public final static String USERNAME = "root";
public final static String PASSWORD = "password";
//插入操作
public static void insert(){
//1加载驱动
try {
Class.forName("com.mysql.jdbc.Driver");
//2获取数据库连接
Connection conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
//3构造SQL语句
String sql = "insert into person(name,age,description)value('小白',18,'一个人')";
//4构造一个statement实例(用来发送 语句的载体)
Statement state = conn.createStatement();
//5执行语句
state.executeUpdate(sql);
//6关闭连接,释放资源
state.close();
conn.close();
System.out.println("success");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
insert();
}
}
这里是错误,看不懂,不知道错在哪里
Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:260)
at BotherDatebase.JdbcDemo.insert(JdbcDemo.java:15)
at BotherDatebase.JdbcDemo.main(JdbcDemo.java:39)
Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.Signature
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询