标签:code system learn exce red 操作 soft generated root
private void cDatabase() { // TODO Auto-generated method stub java.sql.PreparedStatement ps = null; java.sql.Connection cn = null; ResultSet rs = null; try { // Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Class.forName("com.mysql.jdbc.Driver").newInstance(); cn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/learn?user=root&password=&useUnicode=true&characterEncoding=UTF8"); ps = cn.prepareStatement("create database vvv"); int i= ps.executeUpdate(); System.out.println(i); if(i>=1) { System.out.println("数据库新增:成功"); }else { System.out.println("数据库新增:失败"); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { ps.close(); cn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
mysql数据库__Jdbc直接操作__PreparedStatement__新增数据库
标签:code system learn exce red 操作 soft generated root
原文地址:http://www.cnblogs.com/wujianbo123/p/7637040.html