標籤:word char red highlight har ros block trace int
一、代碼如下
private void cTable() {// TODO Auto-generated method stubjava.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 table xxxx(aa int)");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 blocke.printStackTrace();} finally {try {ps.close();cn.close();} catch (SQLException e) {e.printStackTrace();}}}
mysql資料庫__Jdbc直接操作__PreparedStatement__新增資料表