- cmd进入其他文件
- win10 cmd 启动sql(启动不了就用管理员模式打开)
net start mysql
- jdbc
//加载驱动
Class.forName("com.mysql.jdbc.Driver");
//建立连接
String url = "jdbc:mysql://localhost:3306/jdbc";
Connection conn=DriverManager.getConnection(url);
//建立Statement对象
Statement stmt=conn.createStatement();
//执行SQL查询
String sql="select * from users";
ResultSet rs=stmt.executeQuery(sql);
//建立PreparedStatement对象
String sql="select * from user where userName=? and password=?";
PreparedStatement pstmt=Conn.prepareStatement(sql);
pstmt.setString(1,"admin");
pstmt.setString(2,"liubin");
//执行动态SQL查询
ResultSet rs=pstmt.executeQuery();
//执行insert update delete等语句,先定义sql
stmt.executeUpdate(sql);
//访问结果记录集ResultSet
while(rs.next)
{
out.println("你的第一个字段内容为:"+rs.getString("Name"));
out.println("你的第二个字段内容为:"+rs.getString(2));
}
//关闭资源
rs.close();
stmt.clost();
pstmt.close();
con.close();
- 杀死8080端口
1.netstat -ano | findstr 8080
// 结果会出现
// TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 1872
//下方的xxxx就是LISTENING 后方的数字
2.taskkill /pid xxxx /f
-
Unknown initial character set index ‘255’ received from server.
-
class java.util.Date cannot be cast to class java.sql.Date (java.util.Date is in module java.base of loader ‘bootstrap’; java.sql.Date is in module java.sql of loader ‘platform’)