Jdbc

Rizwan Khan's Avatar, Join Date: Dec 2011
Newbie Member
I want to ask how to send string object or text in the insert query.
or string or text from textfield to database............
reply with small example
0
ewaldhorn's Avatar, Join Date: Feb 2010
Go4Expert Member
I think you'd be best served using a PREPARED STATEMENT.

For example...

Code:
// con is the active Database Connection
// All of this is in a try-catch block
String mySqlString = "update THETABLE set TEXTMESSAGE = ? where MESSAGEID = ?";
PreparedStatement myStatement = con.prepareStatement(mySqlString);

myStatement.setString(1, theVeryLongTextMessage);
myStatement.setInt(2, messageID);

myStatement.executeUpdate();
You could refer to http://docs.oracle.com/javase/tutori.../prepared.html for more information regarding prepared statements.

Good luck with your code.