wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes Need help in batch insert using jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Need help in batch insert using jdbc" Watch "Need help in batch insert using jdbc" New topic

Need help in batch insert using jdbc

charu java

Joined: Dec 05, 2012
Posts: 11

Hi Team,
package com.cc.apps.vv.main;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Map;
import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.Cursor;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.Table;
import com.ibatis.sqlmap.client.SqlMapExecutor;
import com.xx.apps.yy.model.Login;
import java.sql.*;
public class Test {

public static void main(String args[]) throws IOException, SQLException{
Table table = null;
Database db = null;
Login login = null;
ArrayList<Login> rowList = null;
Connection con = null;
Statement st = null;
try {
rowList = new ArrayList();

db = Database.open(new File("C:\\Users\\tt\\Accdb.mdb"));

table = db.getTable("Access");

for(Map<String, Object> row : table) {
login = new Login();

con = DriverManager.getConnection(
"jdbc:as400://system-name/default-schema", "aa",

st = con.createStatement();
String insertTableSQL = "INSERT INTO Master (P_ID,R_ID,LNumber) VALUES (?,?,?)";
PreparedStatement preparedStatement = con.prepareStatement(insertTableSQL);
preparedStatement = con.prepareStatement(insertTableSQL);
for(Login login1 : rowList)
preparedStatement.setString(1, login1.getPId());
preparedStatement.setString(2, login1.getRId());
preparedStatement.setString(3, login1.getLocNum());

} catch (ClassNotFoundException e) {
try {
} catch (SQLException e1) {
The above code will do

1. Read the rows from the access table using jackcess
2.And add the row object to the list.
3Then I have connect the As400 database and batch insert the list values in Master table.

when i run this program am getting following error

Exception in thread "main" java.sql.SQLException: [PWS0082] library(s) not added to the library list.
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:703)
at com.ibm.as400.access.AS400JDBCConnection.setServerAttributes(AS400JDBCConnection.java:4122)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3346)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3216)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3209)
at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1411)
at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1248)
at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:389)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)

I need to do sample batch insert in as400 table.
Please help what mistake am doing .

Thanks in Advance

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10747

@"charu java"
Like I had requested earlier you really need to check your Purple Mooseages and take appropriate action. Please note this is not optional.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link: http://aspose.com/file-tools
subject: Need help in batch insert using jdbc
It's not a secret anymore!