salve.... ho un problemino...
come faccio ad inserire ciò che contiene lo stringBuffer in una tabella..?
il mio stringBuffer è
codice:
StringBuffer scriptText = new StringBuffer();
..........
metre la chiamata al database è
codice:
public static void inserisci(StringBuffer scriptText)
{
String connStr =
"jdbc:mysql://localhost:1980/" +
"test?user=root&password=nicola";
String statement2 =
"INSERT INTO guestbook (message, messageDate) " +
"VALUES (?, ?)";
Connection conn = null;
String PreparedStatement=null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(connStr);
PreparedStatement stmt2 = conn.prepareStatement(statement2);
stmt2.setString(1, scriptText );
stmt2.setObject(2, new java.util.Date());
stmt2.executeUpdate();
stmt2.close();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}catch (SQLException e){
e.printStackTrace();}
// handle any errors
}
mi segnala errore nella riga blu...
sicuramente sbaglio nel passare lo stringbuffer
come faccio a risolvere?
grazie