• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter

I get error
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).
for the following code, what is the wrong?

conn = getConnbyDM();
String sSQL = "INSERT INTO myTable";
sSQL += "(CATEGORY_NAME)";
sSQL += " VALUES (?)";
prepStat = conn.prepareStatement(sSQL);
prepStat.setString(1,cm.getCategoryName());
prepStat = conn.prepareStatement(sSQL);
int i=prepStat.executeUpdate();
0
william007
Asked:
william007
1 Solution
 
suprapto45Commented:
Hi,

Are you sure that myTable only contains one field (CATEGORY_NAME)? And is it VARCHAR?

David
0
 
objectsCommented:
whats the table schema?
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:

conn = getConnbyDM();
String sSQL = "INSERT INTO myTable (CATEGORY_NAME)  VALUES (?)";
prepStat = conn.prepareStatement(sSQL);
prepStat.setString(1,cm.getCategoryName());
int i=prepStat.executeUpdate();

try the above program and as such prepStat = conn.prepareStatement(sSQL); was there twice in your previous program.

also for help check out this link.

http://javaalmanac.com/egs/java.sql/InsertPs.html
0
 
william007Author Commented:
Yes, is that extra line giving problem, thanks:-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now