Thread: java.sql.SQLException:...

Forum : Miscellaneous   31-7-2017 07:32:27 AM
User Image
Lokesh4

Newbie

Joined: Jun 13, 2017

Points: 110

Threads: 20

Posts: 19

Answer Icon java.sql.SQLException:...

| Quote Date : Jul 31, 2017    Views:404    

Can any one help me how to resolve this exception while executing the query
resultSet =psmt.executeQuery(sqlQuery);

Exception:
--------------

java.sql.SQLException: Missing IN or OUT parameter at index:: 1
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1821)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3571)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at com.mhb.service.MechanicAccessor.fetchMechanicDetails(MechanicAccessor.java:25)


tags: jdbc

Comments

User Image
Abhishek3

Newbie

Joined : Jun 25, 2017

Points : 140

Threads: 6

Posts: 26

Re: java.sql.SQLException:...

Reply Date : Jul 31, 2017

Hey Lokesh as i can see your are using PreparedStatement :
1. there is no method like executeQuery(String query) to call over PreparedStatement.
2. before executing query we have to specify positional input parameter "?" 
??eg:


?PreparedStatement psmt=con.prepareStatement("select * from mechanic where mechanic_no=?");
?//set the input parameter to placeholder
?psmt.setInt(1,mechanic_no);
?ResultSet rs=psmt.executeQuery();

hope it helps!



User Image
Lokesh4

Newbie

Joined : Jun 13, 2017

Points : 110

Threads: 20

Posts: 19

Re: java.sql.SQLException:...

Reply Date : Aug 2, 2017

Thank you...
problem resolved prasad...

"Hi Lokesh,

                Could you please provide a code snippet, so that we can help you more. 


"

Replied by NagaPrasad
User Image
NagaPrasad

Newbie

Joined : Jul 17, 2017

Points : 100

Threads: 0

Posts: 1

Re: java.sql.SQLException:...

Reply Date : Aug 2, 2017

Hi Lokesh,

                Could you please provide a code snippet, so that we can help you more. 


User Image
Sriman

Newbie

Joined : Jul 15, 2016

Points : 480

Threads: 636

Posts: 153

Answer IconRe: java.sql.SQLException:...

Reply Date : Jul 31, 2017

In your sql query you declared positional parameter ("?"). But you are not setting the value in preparedStatement.
You have to use pstmt.setInt(1, value) then call pstmt.executeQuery();

Load More

No More Comments