mysql__jdbc
有興趣的,可以加我QQ:245308557
數據庫MySQL。不能運行,需要數據庫
package procedures;
import java.sql.*;
jdbc如何連接mysql數據庫?import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
MySQL最新版本?import java.sql.Statement;
import com.mysql.jdbc.*;
public class testProce {
mysql官方手冊?public static void main(String[] args) {
getJDBC();
}
public static void getJDBC(){
String sql = "select * from thaha";
Connection conn = null;
Statement s =null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql" ,"root","123");
s = conn.createStatement();
rs = s.executeQuery(sql);
while(rs.next()){
p(rs.getInt("fuserid")+" ----- ");
p(rs.getString("fusername")+" ----- ");
p(rs.getString("fpasswrod")+" ----- ");
p(rs.getString("fbirday")+" ----- ");
p(rs.getString("fzhuzhi")+" ----- ");
p(rs.getString(""));
p(rs.getString(""));
p("\n");
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}finally{
try {
rs.close();
s.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public static void p(String s){
System.out.print(s);
}
public static void p(int s){
System.out.print(s);
}
}
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态