我正在将 Sql Server 与 Netbeans 一起使用。我正在使用以下代码执行更新查询
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//Connection establishment
Connection con=DriverManager.getConnection("jdbc:sqlserver://DESKTOP-CU5U75J\\SQLSERVER1;databaseName=SQLConnection","Fateh","Fateh");
//Statement Object
Statement st=con.createStatement();
//For DML use executeUpdate method of Statement Class
st.executeUpdate("INSERT INTO Emp"
+" VALUES("+2+",+Gull)");
//Commit Statement
con.commit();
JOptionPane.showMessageDialog(this, "Message", "The Data is Entered", JOptionPane.INFORMATION_MESSAGE);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Employe.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(Employe.class.getName()).log(Level.SEVERE, null, ex);
}
}
RISEBY
相关分类