Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Fern Sanchez   on Jul 09 In Java Category.

  
Question Answered By: Isaac Williams   on Jul 09

I have slightly modified your code example (see the attachment) ->
ie. the update/insert returns an INT, not a ResultSet.
The error you are reffering to (incompatible types) could be related
to how your 'kairegistration' table fields look like. In your INSERT
statement all data are inserted as String. If the DB field type is a
NUMBER (for example), you have to add your argument as a number as
well (therefore without the quotation marks around).
So check out the definition of your DB table and try the modified
example again.

the modified code lines:


1. stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
2. try {
StringBuffer sql = new StringBuffer();
String sqlString = "";
sql.append("insert into kairegistration values ('");
sql.append(studentid);
sql.append("','");
sql.append(coursenumber);
sql.append("')");
sqlString = sql.toString();

int resultDB = stmt.executeUpdate(sqlString);
}

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on SERVLET JDBC Or get search suggestion and latest updates.


Tagged: