Tag:public database null java
Public static void main (string args[]) { SYSTEM.OUT.PRINTLN (321); preparedstatement ps = null; resultset rs = null; Connection ct = null; try{ class.forname (" Com.microsoft.jdbc.sqlserver.SQLServerDriver "); String url = "Jdbc:microsoft:sqlserver://serverxp.com:1433;databasename=project_ Students "; string user=" sa "; String pwd2 = "SA"; ct = drivermanager.getconnection (URL, USER, PWD2); string sql = "SELECT * from stu where 1=? "; ps=ct.preparestatement (SQL); ps.setstring (1, "1"); rs=ps.executequery (); while (Rs.next ()) { system.out.println (rs.getString ("StuName")); } }catch (Exception&nbsP;ex) { ex.printstacktrace (); }finally{ if (NULL!=RS) { try { rs.close (); } catch (exception e) { // todo: handle exception e.printstacktrace (); } rs=null; } if (NULL!=PS) { try { ps.close (); } catch (Exception e) { // TODO: handle exception e.printstacktrace (); } ps = null; } if (NULL!=CT) { try { ct.close (); } catch (exception e) { // TODO: handle exception e.printstacktrace ();nbsp; } ct=null; } } }