mysql的链接问题
package com.imooc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class DBUtil {
private static final String URL="jdbc:mysql://127.0.0.1:3306/imooc";//地址
private static final String USER="root";
private static final String PASSWORD="123456";
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
//1、加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
//2、获得数据库连接
Connection conn= DriverManager.getConnection(URL, USER, USER);
//通过数据库连接操作数据库,实现增删改查;
Statement sat= conn.createStatement();
ResultSet rs=sat.executeQuery("Select user_name,age from imooc_goddess");
while(rs.next())
{
System.out.println(rs.getString("user_name")+","+rs.getInt("age"));
}
}
}
为什么我的代码不行啊?求各位大神指点