aspose file tools*
The moose likes JDBC and the fly likes insert data into table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "insert data into table" Watch "insert data into table" New topic
Author

insert data into table

Candy Bortniker
Ranch Hand

Joined: Mar 17, 2003
Posts: 123
Thanks to some help, I now have my tables created. I'm now trying to load the data into the first table. I have a file that I'm the info from and trying to insert it in the table.

This is not working but I can't find any examples of what would work. I've found examples for insert literals but not variables.
Help!
[ edited to move code block to the left (to alleviate the pain of scrolling left-right) -ds ]
[ April 27, 2003: Message edited by: Dirk Schreckmann ]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I'll assume that you're using a Statement (from a Connection.createStatement() invocation).
Try this modified code out for size.
Before too long of fussing around with funny looking string concatenation and character escaping and single-quote matching, you'll probably want to discover the use of a PreparedStatement. Try a quick search on this forum for example uses of a PreparedStatement.
[ April 27, 2003: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: insert data into table
 
Similar Threads
amount of text - performance
one more question about inserting data
Problems with .sql(script files) and .properties files. [Using Netbeans]
SQLException:Column count doesn't match value count at row 1
Glassfish + jdbcrealm