谁能告诉我我做错了什么吗。我试图为我的实践创建学生数据库管理系统,但我被困在这里。在这里,我试图连接java文件与mysql在本地服务器上,但得到这个错误。
这是密码
try {
Class.forName("com.mysql.jdbc.Driver");
sqlConn = DriverManager.getConnection(dataConn,username,password);
String str = "insert into studentdata(StudentID,FirstName,LastName,Address,Gender,Mobile,"
+ "Math,Game,DataSci,Analysis,Graphic,DataBase1,Science,English)values"
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pst = sqlConn.prepareStatement(str);
pst.setString(1, txtStudentID.getText());
pst.setString(2, txtFirstName.getText());
pst.setString(3, txtLastName.getText());
pst.setString(4, txtAddress.getText());
pst.setString(5, (String) cboGender.getSelectedItem());
pst.setString(6, txtMobile.getText());
pst.setString(7, (String) cboMaths.getSelectedItem());
pst.setString(8, (String) cboGames.getSelectedItem());
pst.setString(9, (String) cboDataSci.getSelectedItem());
pst.setString(10, (String) cboAnalysis.getSelectedItem());
pst.setString(11, (String) cboGraphic.getSelectedItem());
pst.setString(12, (String) cboDataBase.getSelectedItem());
pst.setString(13, (String) cboScience.getSelectedItem());
pst.setString(14, (String) cboEnglish.getSelectedItem());
int resu = pst.executeUpdate();
System.out.println("result: " + resu);
JOptionPane.showMessageDialog(this,"Student Record Added");
} catch (ClassNotFoundException | SQLException ex) {
java.util.logging.Logger.getLogger(StudentDBMS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
这是我的pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>StudentDBMS</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>unknown-jars-temp-repo</id>
<name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>AbsoluteLayout</artifactId>
<version>SNAPSHOT</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
这是文件的位置
控制台显示错误
The POM for unknown.binary:AbsoluteLayout:jar:SNAPSHOT is missing, no dependency information available
--- exec-maven-plugin:3.0.0:exec (default-cli) @ StudentDBMS ---
Apr 20, 2021 12:36:04 AM StudentDBMS.StudentDBMS btnAddNewActionPerformed
SEVERE: null
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at StudentDBMS.StudentDBMS.btnAddNewActionPerformed(StudentDBMS.java:400)
at StudentDBMS.StudentDBMS.access$100(StudentDBMS.java:26)
at StudentDBMS.StudentDBMS$2.actionPerformed(StudentDBMS.java:130)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6539)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
暂无答案!
目前还没有任何答案,快来回答吧!