Java-MySQL连接
                        
                            时间:2021-07-01 10:21:17
                            帮助过:27人阅读
							                        
                     
                    
                    
                     public class DDLDemo02 {
 2     public static void main(String[] args) throws Exception {
 3         String sql = 
"CREATE TABLE `t_student`(`id` " +
 4                 "BIGINT PRIMARY KEY AUTO_INCREMENT," +
 5                 " `name` VARCHAR(255), `age` INT)";
 6         
 7 //        1.加载注册驱动
 8         Class.forName(
"com.mysql.jdbc.Driver");
 9 //        2.获取连接对象
10         Connection con = DriverManager.getConnection(
"" +
11                 "jdbc:mysql:///jdbcdemo?useSSL=false", 
"root", 
"123456");
12 //        3.获取语句对象
13         Statement statement =
 con.createStatement();
14         
15 //        4.执行SQL
16         statement.executeUpdate(sql);
17         
18 //        5.释放资源close()
19         statement.close();
20         con.close();
21         
 
Java-MySQL连接
标签:row   粘贴   dem   png   jdbc   div   width   ddl   str