-2
请简而言之,我如何从eclipse连接到MySQL。如果你可以给我一个简单的步骤,请举例。从eclipse连接到mysql
请简而言之,我如何从eclipse连接到MySQL。如果你可以给我一个简单的步骤,请举例。从eclipse连接到mysql
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("com.mysql.jdbc:mysql://localhost:3306/NewStudents", "root", "root");
Statement st = con.createStatement();
ResultSet result = st.executeQuery("select * from students");
while (result.next()) {
.....
}
}
catch (ClassNotFoundException e) {
System.out.println("Driver not found");
}
catch (SQLException e) {
e.printStackTrace();
getConnection的第一个参数是url,第二个用户名,第三个密码。 还通过将它添加到您的项目的库中来导入de jdbc驱动程序。
有更好的方法,但这对初学者很简单。
这是一个相同的链接,它解释更多。
http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1
因为它的问题是无法回答的。你需要详细说明。你想要一个MySQL客户端,在这种情况下得到Toad插件。 – Johan 2013-02-24 21:24:03
你想从eclipse IDE(即插件)或从使用Eclipse编写的'Java'程序连接? – iTech 2013-02-24 21:25:30
谷歌JDBC - 有大量的分步指南。 – 2013-02-24 21:42:25