Java Reference
In-Depth Information
String url = "jdbc:inetdae7:localhost:1433?database=LEDES";
String login = "jod";
String password = "jod";
try {
Class.forName("com.inet.tds.TdsDriver").newInstance();
JDBCRowSet rowSet = new JDBCRowSet();
//set url,login and password;
rowSet.setUrl( url );
rowSet.setUsername( login );
rowSet.setPassword( password );
//make the rowset scrollable and updatable
rowSet.setType(ResultSet.TYPE_SCROLL_INSENSITIVE);
rowSet.setConcurrency(ResultSet.CONCUR_UPDATABLE);
//set the sql command
rowSet.setCommand("SELECT * FROM CONTACTS");
//execute the command
rowSet.execute();
if(rowSet.getConcurrency()==ResultSet.CONCUR_UPDATABLE)
System.out.println("Rowset is UPDATABLE");
else
System.out.println("Rowset is READ_ONLY");
// move to the Insert Row
rowSet.moveToInsertRow();
// update the fields of the Insert Row
rowSet.updateInt("company_id", 1050);
rowSet.updateInt("address_info_id", 1004);
rowSet.updateString("FName", "Nigel");
rowSet.updateString("LName", "Thornebury");
rowSet.updateString("phone", "555-456-0123");
rowSet.updateString("fax", "555-456-0129");
// insert the Insert Row into the table
rowSet.insertRow();
Search WWH ::




Custom Search