public static void main(String[] args) { // TODO Auto-generated method stub String url = "jdbc:jtds:sqlserver://127.0.0.1:1433;databaseName=base_name;user=sa;password= pas";//sa身份连接 Connection con = null; Statement stmt = null; //ResultSet rs = null; boolean rs ; try { Class.forName("net.sourceforge.jtds.jdbc.Driver"); con = DriverManager.getConnection(url); stmt = con.createStatement(); System.out.println("end."); String sql1="drop table aa"; rs = stmt.execute( sql1); System.out.println("我删除了一张表"); String SQL = "create table aa(" + " id int null," + "currdate date null,)"; rs = stmt.execute(SQL); System.out.println("我创建了一张表"); // rs = stmt.executeQuery(SQL); /* while (rs.next()) { System.out.println(rs.getString(4) + " " + rs.getString(6)); } */ } catch (Exception e) { e.printStackTrace(); } finally { /*if(rs!=null){ rs.colse(); }*/ if (stmt != null) try { stmt.close(); } catch (Exception e) { } if (con != null) try { con.close(); } catch (Exception e) { } } }