aspose file tools*
The moose likes JDBC and the fly likes java.sql.SQLException :  Missing IN or OUT parameter at index:: 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException :  Missing IN or OUT parameter at index:: 1" Watch "java.sql.SQLException :  Missing IN or OUT parameter at index:: 1" New topic
Author

java.sql.SQLException : Missing IN or OUT parameter at index:: 1

toukhir mujawar
Ranch Hand

Joined: Oct 11, 2006
Posts: 70
i m trying to insert some values into the database and getting this message..

java.sql.SQLException: Missing IN or OUT parameter at index:: 1


the code is as below...


PreparedStatement st = conn.prepareStatement("insert into tbl_jv01 (rec_type,sys_code,bu,pc_mth,pc,zone,circle,div,subdiv,jv_cat,trf_cd,amt_type,amount,acct_type,cc_code,std_mth,pr_mth,bill_dt,due_dt,run_dt,run_time,rtrf,prc_mth,version,tag1) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
ResultSet rs = st.executeQuery();
st.setString(1,getRecType());
st.setString(2,getSysCode());
st.setInt(3,getBu());
st.setInt(4,getPcMth());
st.setInt(5,getPc());
st.setInt(6,getZone());
st.setInt(7,getCircle());
st.setInt(8,getDiv());
st.setInt(9,getSubDiv());
st.setInt(10,getJvCat());
st.setInt(11,getTrfCd());
st.setInt(12,getAmtType());
st.setBigDecimal(13,getAmount());
st.setString(14,getAcctType());
st.setInt(15,getCcCode());
st.setInt(16,getStdMth());
st.setInt(17,getPrMth());
st.setInt(18,getBillDt());
st.setInt(19,getDueDt());
st.setInt(20,getRunDt());
st.setString(21,getRunTime());
st.setInt(22, getRtrf());
st.setInt(23,getPrcMth());
st.setInt(24,getVersion());
st.setInt(25,getTag1());
rs.close();
st.close();

please help me regarding this problem....
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14153
    
  18

Your statement is an INSERT statement.

ResultSet rs = st.executeQuery();

Here you are executing the statement as if it's a query. That's wrong, it's not a query.


[ October 11, 2006: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Moving to our JDBC forum.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException : Missing IN or OUT parameter at index:: 1