package com.imocc.db; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Connection; import java.sql.Statement; public class DBUtil { private static final String URL="jdbc:mysql://127.0.0.1:3306:imocc"; private static final String NAME="root"; private static final String PASSWORD="681879"; public static void main(String args[])throws Exception{ Class.forName("com.mysql.jdbc.Driver"); Connection conn= DriverManager.getConnection(URL,NAME,PASSWORD); Statement stmt= conn.createStatement(); ResultSet rs=stmt.executeQuery("select user_name,age from imocc_goddess"); while(rs.next()){ System.out.println(rs.getString("user_name")+","+rs.getInt("age")); } } }
错误信息:
Exception in thread "main" java.lang.ClassNotFoundException: com.MySQL57.jdbc.Driver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.imocc.db.DBUtil.main(DBUtil.java:15)
肥冰
慕的地6079101
寻梦执着
望远