Originally posted by Jyothi Lature:
Hi,
This could be achieved using Prepared Statement in JDBC API. ACtually, its no differnt from using this from any other db:
PreparedStatement ps2 = conn.prepareStatement(
"INSERT INTO TBL_NAME(COL1,COL2,COL3,COL4,COL5) "+
"VALUES(?, ?, ?, ?, ?)";
-- this sample code sets the values of dynamic parameters
-- to be the values of program variables
ps2.setInt(1, var1);
ps2.setInt(2, var2);
ps2.setDate(3, var3);
ps2.setString(4, var4);
updateCount = ps2.executeUpdate();
Incase, if you want to insert multiple rows, then you cud use batch transaction or put this in a loop..
Thanks, I tried following:
I have created a database DEV and its URL is: jdbc

ointBase

EV.
I then added pbembedded.jar in CLASSPATH Suffix in JVM tab in Admin Console.
I also created a JNDI entry as jdbc/dev.
Then I created a table USER_SALARY in the schema PBPUBLIC.
I want to use the table in my Session Bean to insert rows in this table.
I specified it as:
...
ds = (DataSource)ctx.lookup("jdbc/dev");
conn = ds.getConnection();
pstmt = conn.prepareStatement("INSERT INTO PBPUBLIC.USER_SALARY (USER_NAME, SALARY) VALUES(?,?)");
pstmt.setString(1, userName);
pstmt.setDouble(2, (initialSalary*1.25));
updatecount = pstmt.executeUpdate();
.....
When I run the programs, I see that there is an error message in the server.log file:
"....table USER_SALARY is not found...."
What could be the error?
Any help is appreciated.
Thanks,
Rajeev.