Insert « JDBC « Java Database Q&A

1. java inserting special characters with preparedstatement fails

I am using an HTML form which sends

<input type=hidden name=longdesc value='SMARTNET%^" 8X5XNBD'>
this is done by the following javascript code:
function masinsert(id)
 var currentTime=new Date();

 var button = document.getElementById("m"+id);


2. INSERT SQL in Java

I have a Java application and I want to use SQL database. I have a class for my connection :

public class SQLConnection{
    private static String url = "jdbc:postgresql://localhost:5432/table";

3. PreparedStatement getGeneratedKeys() JDBC

i used getGeneratedKeys after inserting in Batchmode. I presume that the order i with the keys are returned is the same as the inserts in my batched insert statments. I want ...

4. does anybody see wrong with my update or insert queries? I am using prepared statement

public void insertOrUpdate(String customerNumber, Long creditLimitAmount) throws SQLException {

Connection connection2 = UBOCMSSQLConnectionUtill.getMSSqlConnection();
PreparedStatement updatePreparedStatement = null;
PreparedStatement insertPreparedStatement = null;
try {
    String updateQuery ...

5. How to use INSERT INTO ALL statement in jdbc prepared statement with beans

Kindly give me some example that how we can use "INSERT INTO ALL STATEMENT" in jdbc prepared statement inside a jsf bean? Actually i want to take employee id's of present employees ...

6. Bulk insert in Java using prepared statements batch update

I am trying to fill a resultSet in Java with about 50,000 rows of 10 columns and then inserting them into another table using the batchExecute method of PreparedStatement. To make the process ...

7. How should I reuse prepared statements to perform multiple inserts in Java?

So, I have a collection of DTOs that I need to save off. They are backed with a temporary table, and they also need to have their data inserted into ...

8. Java JDBC - Multiple prepared statement bulk insert

Using JDBC (Oracle) I need to insert about thousand rows into each of two tables. Something like this:


9. problem with inserting data in a same column using prepared statement

hi, i am having a problem in inserting the data into database,i have 2 insert 4 rows into a column n every thing the last row overwrites the rest n only the last row is displayed in the database the code is blow,plz help me slove this problem... the opt1,opt2,opt3 are over written by opt4 n only opt4 is there is ...

10. Inserting junk values while using Prepared Statement

Hi all, I am using oracle 8.1.7 and oracle 9i jdbc driver.I am inserting multiple records using prepared statement.I gave auto commit false and i am iterating each record and setting value using prepared statement and calling execute update.Finally after the end of the loop i am doing commit and made setAutoCommit(true).But it is inserting junk values for a particular column ...

12. insert and preparedStatement

13. Use Multiple Insert Statements in Prepared Statements

Hi Friends i am stuck in a problem for which i need your help.i will brief you about the issue below. I am having Multiple Insert Statements which i need to execute to put the data in the database.i have a doubt about the use of the executeUpdate() function in the statement interface. sample code is as below. stmt = conn.prepareStatement("INSERT ...

15. Error during large batch insertion for preparedstatement (395 parameters)

Hi, I am using db2 and jdbc preparedstatements in java to insert a large number of columns (395 parameters in this example), and I have about 20 other tables with similar column sizes, and are inserting in a batch. I am getting an error when trying to do this, is there a limitation to the number of parameters I can use? ...

17. how can we use where clause with insert query using preparedStatement?

but as I need some field extra in history_grocery and some missing from grocery it this case what i should do??? like.. CREATE TABLE `history_grocery` ( `auto_generate` int(100) NOT NULL AUTO_INCREMENT, `subcategory` varchar(100) DEFAULT NULL, `grocery_name` varchar(100) DEFAULT NULL, `units` varchar(100) DEFAULT NULL, `price_tqty` varchar(100) DEFAULT NULL, `quantity` varchar(100) DEFAULT NULL, `total_amount` varchar(100) DEFAULT NULL, `username` varchar(100) DEFAULT NULL, `current_date_time` datetime ...

18. problem when inserting a row with prepared Statement

HI everyone, I'm new to Java and I am trying to write a program that selects employees from the database, calculates their average salary and then inserts all new lines to a newly created table in the database. I am having issues with inserting the tables. I am able to print to the screen all rows with the employees and their ...

19. PreparedStatement not inserting Strings

I'm sorry I'm quite new to this, but doesn't the setUsername(String value) and setDescription(String value) in the code supposed to set the variables? I've tested just echoing the values and they seem to be doing the job. Also when I use just Statement to insert the data it works fine. It just doesn't work with PreparedStatement.