Greetings,
I am attempting to build valid SQL using prepared statements and SQL parameter passing. PreparedStatement has a method called setString which assigns values to parameters of a prepared statement.
According to the Jbuilder Java docs, there should be two implementations of this method:
1. setString(int ordinal, String value)
2. setString(String columnName, String value)
However, I only seem to have the first (integer) implementation available. I need to use the second (string)implementation since assigning parameters by column names would be much more usefull to me for what I am trying to do.
Why is the setString(String columnName, String value) method not in my PreparedStatement class? How do I add it?
Thanks for the help,
Draug
Below is a snippet of my code that works fine with the integer implementation of setString.
Code Snippet:
===========================================================
String qry = null;
PreparedStatement ps = null;
ResultSet rset = null;
qry = "SELECT * FROM WELLS WHERE Well_Id=? AND Site_Id=?";
ps = conn.prepareStatement(queryString);
ps.setString(1, "1" //parameter 1 is Well_Id
ps.setString(2, "27038" //paremeter 2 is Site_Id
rset = ps.executeQuery();
===========================================================
I am attempting to build valid SQL using prepared statements and SQL parameter passing. PreparedStatement has a method called setString which assigns values to parameters of a prepared statement.
According to the Jbuilder Java docs, there should be two implementations of this method:
1. setString(int ordinal, String value)
2. setString(String columnName, String value)
However, I only seem to have the first (integer) implementation available. I need to use the second (string)implementation since assigning parameters by column names would be much more usefull to me for what I am trying to do.
Why is the setString(String columnName, String value) method not in my PreparedStatement class? How do I add it?
Thanks for the help,
Draug
Below is a snippet of my code that works fine with the integer implementation of setString.
Code Snippet:
===========================================================
String qry = null;
PreparedStatement ps = null;
ResultSet rset = null;
qry = "SELECT * FROM WELLS WHERE Well_Id=? AND Site_Id=?";
ps = conn.prepareStatement(queryString);
ps.setString(1, "1" //parameter 1 is Well_Id
ps.setString(2, "27038" //paremeter 2 is Site_Id
rset = ps.executeQuery();
===========================================================