It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes insert data into table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "insert data into table" Watch "insert data into table" New topic

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.
[ 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

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:
subject: insert data into table
It's not a secret anymore!