Atomic transaction when using JDBC call after Hibernate processes - java

I get that code:
#Override
public void bulkInsert(Collection<SortingPlanData> data, SortingPlan plan) {
Session session = getEntityManager().unwrap(Session.class);
SessionFactoryImplementor sessionFactoryImplementation = (SessionFactoryImplementor) session
.getSessionFactory();
ConnectionProvider connectionProvider = sessionFactoryImplementation
.getConnectionProvider();
String sql = "insert into SORTING_PLAN_DATA (ACHEMINEMENT, ANCIEN_GROUPE_SERVICE_LABELS, BAG_ID, BARCODE_ID, CHRONOSERVICE, CODE_ROUTING, D_DEPOT_NUMBER, D_SORT, DELIVERY_STATION, DESCRIPTION, DESTINATION_PAYS_ALPHA2_ISO, DESTINATION_PAYS_ALPHA3_ISO, DESTINATION_PAYS_NUM_ISO,"
+ " DIST, GROUPE_SERVICE_LABELS, GROUPING_PRIORITY, LIVRAISON, O_SORT, ORIGINE_PAYS_ALPHA2_ISO, ROUTING_PLACES, S_SORT, SENDING_DATE, SERVICE_CODES, SITE_IATA, SORTING_PLAN_ID, TYPE_EXPORT, VILLE, ZIP_MAX, ZIP_MIN) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
Transaction tx = session.getTransaction();
final int batchSize = 500;
int count = 0;
try {
tx.begin();
Connection con = connectionProvider.getConnection();
PreparedStatement ps = con.prepareStatement(sql);
for (SortingPlanData spd : data) {
ps.setString(1, spd.getAcheminement());
ps.setString(2, spd.getAncienGroupeServiceLabels());
ps.setString(3, spd.getBagId());
ps.setString(4, spd.getBarcodeId());
ps.setString(5, spd.getChronoservice());
ps.setString(6, spd.getCodeRouting());
ps.setString(7, spd.getDDepotNumber());
ps.setString(8, spd.getDSort());
ps.setString(9, spd.getDeliveryStation());
ps.setString(10, spd.getDescription());
ps.setString(11, spd.getDestinationPaysAlpha2Iso());
ps.setString(12, spd.getDestinationPaysAlpha3Iso());
ps.setInt(13, spd.getDestinationPaysNumIso());
ps.setString(14, spd.getDist());
ps.setString(15, spd.getGroupeServiceLabels());
ps.setString(16, spd.getGroupingPriority());
ps.setString(17, spd.getLivraison());
ps.setString(18, spd.getOSort());
ps.setString(19, spd.getOriginePaysAlpha2Iso());
ps.setString(20, spd.getRoutingPlaces());
ps.setString(21, spd.getSSort());
ps.setDate(22, new java.sql.Date(System.currentTimeMillis()));
ps.setString(23, spd.getServiceCodes());
ps.setString(24, spd.getSiteIata());
ps.setLong(25, plan.getId());
ps.setString(26, spd.getTypeExport());
ps.setString(27, spd.getVille());
ps.setString(28, spd.getZipMin());
ps.setString(29, spd.getZipMax());
ps.addBatch();
count++;
if (count % batchSize == 0) {
ps.executeBatch();
LOGGER.info(count + " lines inserted do far in");
}
}
ps.executeBatch(); // insert remaining records
ps.close();
con.close();
} catch (SQLException e) {
tx.rollback();
throw new HibernateException(e.getMessage(), e.getCause());
}
tx.commit();
}
The bulkInsert method is called from a class which itself is annotated with #Transactional, and of course, I get an Exception on tx.begin():
org.hibernate.TransactionException: nested transactions not supported
Problem is, I have no idea on how to retrieve the existing transaction and transmit it to my bulkInsert() method. Any leads?
I'm using Java 6, with Hibernate 4, Spring 3.2.3 on a Sybase 15.5 database.

You are making it way to complex, use a [JdbcTemplate][1] which uses the same DataSourceas your EntityManagerFactory. This will obtain the current connection and automatically participate in the already ongoing transaction. Next to that it will greatly simplify your code.
#Autowired
private JdbcTemplate jdbcTemplate
#Override
public void bulkInsert(Collection<SortingPlanData> data, SortingPlan plan) {
String sql = "insert into SORTING_PLAN_DATA (ACHEMINEMENT, ANCIEN_GROUPE_SERVICE_LABELS, BAG_ID, BARCODE_ID, CHRONOSERVICE, CODE_ROUTING, D_DEPOT_NUMBER, D_SORT, DELIVERY_STATION, DESCRIPTION, DESTINATION_PAYS_ALPHA2_ISO, DESTINATION_PAYS_ALPHA3_ISO, DESTINATION_PAYS_NUM_ISO,"
+ " DIST, GROUPE_SERVICE_LABELS, GROUPING_PRIORITY, LIVRAISON, O_SORT, ORIGINE_PAYS_ALPHA2_ISO, ROUTING_PLACES, S_SORT, SENDING_DATE, SERVICE_CODES, SITE_IATA, SORTING_PLAN_ID, TYPE_EXPORT, VILLE, ZIP_MAX, ZIP_MIN) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
jdbcTemplate.batchUpdate(sql, data, 500, new ParameterizedPreparedStatementSetter<SortingPlanData>() {
public void setValues(PreparedStatement ps, SortingPlanData spd) throws SQLException {
ps.setString(1, spd.getAcheminement());
ps.setString(2, spd.getAncienGroupeServiceLabels());
ps.setString(3, spd.getBagId());
ps.setString(4, spd.getBarcodeId());
ps.setString(5, spd.getChronoservice());
ps.setString(6, spd.getCodeRouting());
ps.setString(7, spd.getDDepotNumber());
ps.setString(8, spd.getDSort());
ps.setString(9, spd.getDeliveryStation());
ps.setString(10, spd.getDescription());
ps.setString(11, spd.getDestinationPaysAlpha2Iso());
ps.setString(12, spd.getDestinationPaysAlpha3Iso());
ps.setInt(13, spd.getDestinationPaysNumIso());
ps.setString(14, spd.getDist());
ps.setString(15, spd.getGroupeServiceLabels());
ps.setString(16, spd.getGroupingPriority());
ps.setString(17, spd.getLivraison());
ps.setString(18, spd.getOSort());
ps.setString(19, spd.getOriginePaysAlpha2Iso());
ps.setString(20, spd.getRoutingPlaces());
ps.setString(21, spd.getSSort());
ps.setDate(22, new java.sql.Date(System.currentTimeMillis()));
ps.setString(23, spd.getServiceCodes());
ps.setString(24, spd.getSiteIata());
ps.setLong(25, plan.getId());
ps.setString(26, spd.getTypeExport());
ps.setString(27, spd.getVille());
ps.setString(28, spd.getZipMin());
ps.setString(29, spd.getZipMax());
}
});
}

Related

Importing .csv into SQLite in Java

I have to write a programm that automatically reads out of my .csv and puts the data into my SQLite. This code fills up the first line in my table, which I created before.
How to I skip/go to the next line, to fill it up?
I guess its something in the loop, but Im not sure what to change...
(I skipped the first line, because it contains the columns.)
Code:
public static void read()
{
String csv = "C:\\Users\\schneider\\Desktop\\Schneider\\Excel\\DienstbarkeitenTabelle.csv";
BufferedReader br = null;
String line = "";
String csvSplitBy = ",";
int currentLine = 0;
Connection conn = null;
try
{
conn = DriverManager.getConnection("jdbc:sqlite:C:/sqlite/db/tollerName");
PreparedStatement prep = conn.prepareStatement("insert into tollerName(Bauprojekt, Bauprojektnummer, Auftragsnummer,Trassierung, JahrSAP, ProjektnummerSPA, Anlagenzahl, AktuelleLeitungslaenge, VorgaengeZumProjekt, VertraegeZumProjekt, Firma, Flurst, Blatt, Verf, Anl, RE, LL, BreiteSS, FlaecheRA, Entsch, Haupteigentuemer, Gemarkung, Grundbuchamt, Strase, Hausnummer, Hausnummerzusatz, Ort, plz, VkWert, prozentBPD, Anlage, GFR, GBA, Empfaenger, Bank, IBAN, BIC, von, an, JahrDerVergabe, Zahlungsgrund, Netto, Aufwand, Umsatzsteuer) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
br = new BufferedReader(new FileReader(csv));
while((line = br.readLine()) != null)
{
if(currentLine > 0)
{
String[] table = line.split(csvSplitBy);
prep.setString(1, (table[0]));
prep.setString(2, (table[1]));
prep.setString(3, (table[2]));
prep.setString(4, (table[3]));
prep.setString(5, (table[4]));
prep.setString(6, (table[5]));
prep.setInt(7, Integer.parseInt(table[6]));
prep.setDouble(8, Double.parseDouble(table[7]));
prep.setInt(9, Integer.parseInt(table[8]));
prep.setInt(10, Integer.parseInt(table[9]));
prep.setString(11, (table[10]));
prep.setString(12, (table[11]));
prep.setString(13, (table[12]));
prep.setString(14, (table[13]));
prep.setString(15, (table[14]));
prep.setString(16, (table[15]));
prep.setDouble(17, Double.parseDouble(table[16]));
prep.setDouble(18, Double.parseDouble(table[17]));
prep.setDouble(19, Double.parseDouble(table[18]));
prep.setDouble(20, Double.parseDouble(table[19]));
prep.setString(21, (table[20]));
prep.setString(22, (table[21]));
prep.setString(23, (table[22]));
prep.setString(24, (table[23]));
prep.setString(25, (table[24]));
prep.setString(26, (table[25]));
prep.setString(27, (table[26]));
prep.setString(28, (table[27]));
prep.setDouble(29, Double.parseDouble(table[28]));
prep.setDouble(30, Double.parseDouble(table[29]));
prep.setString(31, (table[30]));
prep.setString(32, (table[31]));
prep.setString(33, (table[32]));
prep.setString(34, (table[33]));
prep.setString(35, (table[34]));
prep.setString(36, (table[35]));
prep.setString(37, (table[36]));
prep.setString(38, (table[37]));
prep.setString(39, (table[38]));
prep.setString(40, (table[39]));
prep.setString(41, (table[40]));
prep.setDouble(42, Double.parseDouble(table[41]));
prep.setDouble(43, Double.parseDouble(table[42]));
prep.setDouble(44, Double.parseDouble(table[43]));
prep.execute();
conn.commit();
}
currentLine++;
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if(br == null)
try
{
br.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
System.out.println("müsste feddich sein");
}
You initialize currentLine to 0, the first time you pass in your loop the condition if(currentLine > 0) is false, that's why the first line is not inserted.
unless you have deleted some important part of your code the test is useless. currenltLine is only incremented starting from 0, it can never be negative nor null.

How to get a generated UUID type using JDBC getGeneratedKeys?

This is specific to MySQL and UUID type of id for which I am using uuid() function of MySQL itself. It's giving me not null resultSet, but next() value is always empty.
Following is the code:
String insertQuery = "INSERT INTO fixtures "
+ "(id, whatever1, whatever2, whatever3, whatever4, "
...
+ "created_at) "
+ "VALUES(UUID(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
PreparedStatement preparedStatement = connection.prepareStatement(insertQuery, Statement.RETURN_GENERATED_KEYS);
.
.
.
preparedStatement.setDate(23, sqlDate);
preparedStatement.executeUpdate();
ResultSet keysResultSet = preparedStatement.getGeneratedKeys();
System.out.println(keysResultSet); // com.mysql.cj.jdbc.result.ResultSetImpl#6892b3b6
if(keysResultSet != null && keysResultSet.next()){
System.out.println("Generated Emp Id: "+keysResultSet.getString("id"));
} else {
System.out.println("No KEYS GENERATED");
}
There is no key generated, but actually provided:
So either leave the creation to the database:
String insertQuery = "INSERT INTO fixtures "
+ "(whatever1, whatever2, whatever3, whatever4, "
...
+ "created_at) "
+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, "
+ "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
As I am not aware of how to easily achieve a UUID on the MySQL side, I would suggest the original solution with a UUID on java side:
String insertQuery = "INSERT INTO fixtures "
+ "(id, whatever1, whatever2, whatever3, whatever4, "
...
+ "created_at) "
+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?, "
+ "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
UUID id = UUID.randomUUID();
preparedStatement.setString(1, id.toString());
Getting the UUID then becomes irrelevant.
For SQL Server 2008 and later you can define a primary key using an auto-generated UUID. To retrieve the UUID generated by the INSERT statement, add the OUTPUT option after your column definitions, and replace your statement.executeUpdate for statement.executeQuery and retrieve the value from the ResultSet. Here is a code fragment showing how to do it:
sqlStmt.append("INSERT INTO tableName");
sqlStmt.append(" (column1");
sqlStmt.append(", column2");
...
sqlStmt.append(" OUTPUT inserted.columnUUID");
sqlStmt.append(" VALUES (?, ?, ?, ?) ");
statement = connection.prepareStatement(sqlStmt.toString());
statement.clearParameters();
int index = 0;
ResultSet resultSet = statement.executeQuery();
if (resultSet.next())
{
result = resultSet.getString(1);
companyDB.varUUID = result;
}
Jop Eggan's answer solves it. However, you can do the following too in case the approach gives any errors:
String insertQuery = "INSERT INTO fixtures "
+ "(id, whatever1, whatever2, whatever3, whatever4, "
...
+ "created_at) "
+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?, "
+ "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
UUID id = UUID.randomUUID();
preparedStatement.setObject(1, id);

SQL Exception: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0)

try {
Class.forName("com.mysql.jdbc.Driver");
String connectionUrl = "jdbc:mysql://Localhost/basic_credit? autoReconnect=true&useSSL=false" ;
Connection con = DriverManager.getConnection(connectionUrl,"root","superchan009");
String sql="INSERT INTO new_table(date, time, customer_name, address, contact#1, contact#2, item_name, final_price, downpayment, remaining_balance, length_ofinstallment, payment_permonth, first_due, last_due)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1,jLabel16.getText());
ps.setString(2,jLabel17.getText());
ps.setString(3,tf1.getText());
ps.setString(4,tf2.getText());
ps.setString(5,tf3.getText());
ps.setString(6,tf4.getText());
ps.setString(7,tf6.getText());
ps.setString(8,tf7.getText());
ps.setString(9,tf8.getText());
ps.setString(10,tf9.getText());
ps.setString(11,tf10.getText());
ps.setString(12,tf11.getText());
ps.setString(13,tf12.getText());
ps.setString(14,tf13.getText());
ps.executeUpdate();
JOptionPane.showMessageDialog(null,"DATA SAVED! THANK YOU!");
} catch (SQLException e) {
System.out.println("SQL Exception: "+ e.toString());
} catch (ClassNotFoundException cE) {
System.out.println("Class Not Found Exception: "+ cE.toString());
}
you are using # in column name is creating issue... you should remove # tag from column name and also correct it into database.
try {
Class.forName("com.mysql.jdbc.Driver");
String connectionUrl = "jdbc:mysql://Localhost/basic_credit? autoReconnect=true&useSSL=false" ;
Connection con = DriverManager.getConnection(connectionUrl,"root","superchan009");
String sql="INSERT INTO new_table(date, time, client_name, address, contact1, contact2, item_name, final_price, downpayment, remaining_balance, length_ofinstallment, payment_permonth, first_due, last_due) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1,jLabel16.getText());
ps.setString(2,jLabel17.getText());
ps.setString(3,tf1.getText());
ps.setString(4,tf2.getText());
ps.setString(5,tf3.getText());
ps.setString(6,tf4.getText());
ps.setString(7,tf6.getText());
ps.setString(8,tf7.getText());
ps.setString(9,tf8.getText());
ps.setString(10,tf9.getText());
ps.setString(11,tf10.getText());
ps.setString(12,tf11.getText());
ps.setString(13,tf12.getText());
ps.setString(14,tf13.getText());
ps.executeUpdate();
JOptionPane.showMessageDialog(null,"DATA SAVED! THANK YOU!");
} catch (SQLException e) {
System.out.println("SQL Exception: "+ e.toString());
} catch (ClassNotFoundException cE) {
System.out.println("Class Not Found Exception: "+ cE.toString());
}
SQL to JAVA connection is case sensitive if you're going to use special char "#" for column names.

Invalid column index in preparedStatement

I'm trying to insert a value in a DB table and I keep stumbling on the Invalid Column Index error.
Here's a code sample:
String insertNewAlarmStat =
"insert into alarmes (id_alarm, alarm_key, id_notif, sever, urgency, date_hour_start, date_hour_modif, date_hour_end, " +
"state, state_rec, date_hour_rec, id_user_rec, id_system_rec, " +
"type, cause, " +
"num_events, id_entity_g, type_entity_g, " +
"desc_entity_g, problem, " +
"time_urg_act, max_urg_act, time_end, time_arq, lim, rec_oblig, dn, num_events_ps, id_alarm_o, id_notif_o, text_ad, domain, date_hour_reg) " +
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE, SYSDATE, SYSDATE, SYSDATE, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE)";
PreparedStatement prpstmt = null ;
try {
prpstmt = conn.prepareStatement(insertNewAlarmStat);
prpstmt.setInt(1, randomNumberGenerator());
prpstmt.setString(2, UUID.randomUUID().toString());
prpstmt.setString(3, UUID.randomUUID().toString());
prpstmt.setInt(4, randomNumberGenerator());
prpstmt.setInt(5, 8);
prpstmt.setInt(6, 8524);
prpstmt.setString(7, UUID.randomUUID().toString());
prpstmt.setString(8, UUID.randomUUID().toString());
prpstmt.setString(9, UUID.randomUUID().toString());
prpstmt.setString(10, UUID.randomUUID().toString());
prpstmt.setString(11, "KABOOM");
prpstmt.setInt(12, 8);
prpstmt.setDate(13, getCurrentDate());
prpstmt.setDate(14, getCurrentDate());
prpstmt.setDate(15, getCurrentDate());
prpstmt.setDate(16, getCurrentDate());
prpstmt.setInt(17, 43);
prpstmt.setString(18, UUID.randomUUID().toString());
prpstmt.setString(19, UUID.randomUUID().toString());
prpstmt.setString(20, UUID.randomUUID().toString());
prpstmt.setString(21, UUID.randomUUID().toString());
prpstmt.setInt(22, 2);
prpstmt.setInt(23, 224);
prpstmt.setInt(24, 2);
prpstmt.setInt(25, 224);
prpstmt.setInt(26, 2);
prpstmt.setInt(27, 4);
prpstmt.setInt(28, 2);
prpstmt.setString(29, null);
prpstmt.setString(30, UUID.randomUUID().toString());
prpstmt.setString(31, UUID.randomUUID().toString());
prpstmt.setInt(32, 2);
prpstmt.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I've tried to remove the prpstmt from 13 to 16 but it complains that those indexes are missing, I've tried other stuff as well but I can't get this to work.
What am I doing wrong?
remove
prpstmt.setDate(13, getCurrentDate());
prpstmt.setDate(14, getCurrentDate());
prpstmt.setDate(15, getCurrentDate());
prpstmt.setDate(16, getCurrentDate());
and instead of 17, start from 13 again..
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE, SYSDATE, SYSDATE, SYSDATE, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE
1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,SYSDATE, SYSDATE, SYSDATE, SYSDATE,13,14.... etc
There are 33 columns in this insert statement. There are 33 values -- 28 ? place holders and 5 literal values (sysdate). The indexes in the setXYZ methods refer to the index of the ? placeholders, not the index into the values of the insert statement.
For the sysdate values, you don't need to do anything, so remove those calls to setDate. But for values beyond the first 4 sysdates, you just need to use the next value, which is 13, not 17.
prpstmt.setInt(1, randomNumberGenerator());
// snip
prpstmt.setInt(12, 8);
// calls to `setDate(13-16, getCurrentDate());` removed
prpstmt.setInt(13, 43); // changed 17 to 13
// snip
prpstmt.setInt(28, 2); // changed 32 to 28
What is sysdate?
sysdate is an Oracle function that returns the current date/timestamp, equivalent to Calendar.getInstance() in Java. For the purposes of JDBC, it's a value that is already supplied in the insert statement.
Your query String contains 28 question marks, I wrote a program to count for you
String str = "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE, SYSDATE, SYSDATE, "
+ "SYSDATE, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE)";
int count = 0;
for (char ch : str.toCharArray()) {
if (ch == '?') {
count++;
}
}
System.out.println(count);
So, you can't bind 32 parameters. I think your
prpstmt.setDate(13, getCurrentDate());
prpstmt.setDate(14, getCurrentDate());
prpstmt.setDate(15, getCurrentDate());
prpstmt.setDate(16, getCurrentDate());
Are hard coded to SYSDATE in the query. So, remove the four SYSDATE(s) in the middle of the query
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
+ "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE)";
And you'd have 32.

How to insert into two or more different tables in MySQL using Java

String Sql = " INSERT INTO asset_update
(asset_id,
date_acquired,
item_code,
serial_number,
cost_of_acquisition,
estimated_useful_life,
estimated_residual_value,
depreciation_start_date,
USER,
status,
disposal_date,
asset_image)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
pst = conn.prepareStatement(Sql);
pst.setString(1, assetid.getText());
pst.setString(2, ((JTextField) date_aquired.getDateEditor().getUiComponent()).getText());
String itemCode = ComboBox_itemCode.getSelectedItem().toString();
pst.setString(3, itemCode);
pst.setString(4, txt_sn.getText());
pst.setString(5, txt_coa.getText());
pst.setString(6, eul.getText());
pst.setString(7, txt_erv.getText());
pst.setString(8, ((JTextField) date_dsd.getDateEditor().getUiComponent()).getText());
String user = jComboBox_Users.getSelectedItem().toString();
pst.setString(9, user);
String status = ComboBox_status.getSelectedItem().toString();
pst.setString(10, status);
pst.setString(11, ((JTextField) date_dd.getDateEditor().getUiComponent()).getText());
pst.setBytes(12,persons_image);
this my code but what if i want to add another table with different columns to my insert statement

Categories