不能从 Connection 转换为 Connection

qazwsxhai CSDN会员 qazwsxhai 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

import java.beans.Statement;
import com.sun.corba.se.pept.transport.Connection;
import java.sql.*;

public class aa{
public static void main(String[] args){
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
try {
Connection con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/guestbook", "root","123");
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
try {
// Statement st = con.
// ResultSet rs = st.
// //ResultSet rs = stmt.execute("select * from messges");
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
}


Connection con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/guestbook", "root","123");
这句提示类型不匹配:不能从 Connection 转换为 Connection 怎么回事的?

还有,实例化了Statement 到st上.它却找不到executeQuery()这个方法...




...全文
评论 6
收藏 已收藏
分享
返回顶部
qazwsxhai CSDN会员
Java SE 62,620 成员 307,251 内容