Results 1 to 3 of 3
- 02-19-2010, 03:47 AM #1
Member
- Join Date
- Feb 2010
- Location
- Philippines
- Posts
- 20
- Rep Power
- 0
Calling Stored Procedures from oragle10g
please help me with my code i cant seem to run it from java
i have google sample codes and try using it but it dosnt work
String sql = "call pckg_insert_event.trakout('" + lt.getLotClass() + lt.getLotNo() +"','"+lt.getDevice()+"',"+ lt.getWaferQty() + "," + lt.getShipQty() + ",'"+ lt.getInvoiceNo() + "')";
CallableStatement cStmt = conn.prepareCall(sql);
The SQL statement is this
call pckg_insert_event.trakout('AJ1234567890','ORMIC-012',2,2008,'1234567890')
- 02-19-2010, 04:58 AM #2
I think the sql statement needs to be enclosed in "{" and "}". Its some kind of JDBC escape notation.
as,
Though, CallableStatement extends PreparedStatement. I think its better to make use of positional parameters where possible, to avoid problems if the string variable values contain single quotes and needing to escape these, or to prevent sql injection attacks, if it is ever possible one of these string values could be entered from an end user form input field.Java Code:String sql = "{ call pckg_insert_event.trakout('" + lt.getLotClass() + lt.getLotNo() +"','"+lt.getDevice()+"',"+ lt.getWaferQty() + "," + lt.getShipQty() + ",'"+ lt.getInvoiceNo() + "') }";
Java Code:String sql = "{ call pckg_insert_event.trakout(?, ?, ?, ?, ?) }"; CallableStatement cStmt = conn.prepareCall(sql); cStmt.setString(1, lt.getLotClass() + lt.getLotNo() ); cStmt.setString(2, lt.getDevice()); cStmt.setInt (3, lt.getWaferQty()); cStmt.setInt (4, lt.getShipQty()); cStmt.setString(5, lt.getInvoiceNo()); cStmt.execute();
- 02-19-2010, 05:17 AM #3
Member
- Join Date
- Feb 2010
- Location
- Philippines
- Posts
- 20
- Rep Power
- 0
Similar Threads
-
Stored Procedures
By geeta_ravikanti in forum JDBCReplies: 1Last Post: 04-22-2008, 02:34 AM -
Calling SQL Server stored procedures
By Java Tip in forum Java TipReplies: 0Last Post: 01-07-2008, 08:40 AM -
Stored Procedures with java
By Albert in forum JDBCReplies: 4Last Post: 06-08-2007, 05:59 AM -
stored procedures in Hibernate
By Alan in forum JDBCReplies: 2Last Post: 05-31-2007, 04:49 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks