• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issue with entering data from Java class file to Database

 
rajarshi roy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a Java class file to read data from an Excel sheet using the Apache POI API,and then using Preparedstatement to finally enter the data into database.Now I am using an insert statement in a for-loop that enters one set of data at one time.
Somewhat like this....


This process seems to take a lot of time.Data is read from the Excel sheet instantly.But it takes time to insert in to the table.Is there any way,that I store all the data in an Array/ArrayList and then finally enter them altogether,at once,instead of entering one set of data at one time? I think if it can be done,then the entire process will become much faster.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34218
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. There is an executeBatchUpdate() method you can use to have less trips to the database. Depending on the size of the file, you may want to read parts of the file at a time (in a loop) so you don't have the whole file in memory.
 
rajarshi roy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not getting it.My problem is I am using an insert statement in a for-loop to enter data.I want to do the transaction at once.Let us say that I concatenate the data in a comma-separated String,or put the data in to an array and then insert it altogether.

I was trying to use ArrayDescriptor. But I am facing this weird exception


Exception encountered 1java.sql.SQLException: invalid name pattern: apps.hr_type_nom_temp
Exception encountered 3java.sql.SQLException: invalid name pattern: apps.hr_type_nom_temp



The code is, as follows



Any idea,where exactly I am making the mistake?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roy,
Interface Statement declares method addBatch.
I suggest you search the Internet for "addBatch example".

And by the way, Jeanne, I could not find any method named executeBatchUpdate in the javadocs.

Good Luck,
Avi.

 
Krish Khan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,



I am trying to read an excel which has Thai language init I could able to read the file but the thai characters are appearing as ??? ??? instead of "นายสุรชัย พิมพ์รำลึก".


my code is :



You can use this code to read ordinary(English characters) Excel (.xls). Please try this code it may help you .

And also I am looking for someone who can solve my problem of reading thai language characters and saving it in database.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic