I'm trying to store the contents of a text file onto a database. The text is no more than 1000 characters long. How do I do this?
1 Answer
To save content of Text file into Database.
- Create a table with
CLOB - Use
java.io.Readerto read the text file - Use JDBC API (PreparedStatement) to execute INSERT statement.
String sql="INSERT INTO TableName (clobCol) VALUES (?)"; PrepareStatement ps=connection.prepareStatement(sql); ps.setClob(1,readerObject);
2 Comments
Evil Washing Machine
Just InputStream? Googling around I get C# results which imply that the steps are much more complicated, which is actually what's confusing me!
Mark Rotteveel
No, a
Reader, you are dealing with character data.