473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

java.sql.SQLException: ORA-01006: bind variable does not exist

4
hi
i am trying to update a table selecting a value from another table and ve written the following codes for it..

import java.sql.*;
import java.io.*;
import java.util.*;

public class AF_updateAlleleTmp
{
Connection m_alleleCon;

public void con() throws SQLException, java.lang.ClassNotFoundException
{
Class.forName("oracle.jdbc.driver.OracleDriver"); // oracle driver
m_alleleCon = (Connection)DriverManager.getConnection("jdbc:orac le:thin:@192.168.2.222:1521:SNPDB","g2p","g2p");

}

public void updateAlleleTemp() throws Exception
{
Statement my_updateStmt=m_alleleCon.createStatement(); //:1<int>,:2<char[32]>,:3<double>,:4<char[128]>)
PreparedStatement my_SelMTStmt=m_alleleCon.prepareStatement("select distinct(AutoMarkerID) from marker_temp where marker_temp.dbSNPrsID=?");
System.out.println("after 1");
PreparedStatement my_updateATPStmt=m_alleleCon.prepareStatement("upd ate allele_temp set allele_temp.AutoMarkerID =? where dbsnprsid=? and automarkerid is null");
System.out.println("after 2");
ResultSet AT_amid=my_updateStmt.executeQuery("select * from missingautomarkerid");
System.out.println("after 3");
while (AT_amid.next())
{

System.out.println("inside while");
String dbsnpStr=AT_amid.getString("dbsnprsid");
System.out.println("got dbsnprsid\t"+dbsnpStr);

my_SelMTStmt.setString(1,dbsnpStr);
System.out.println("sel stmt");
//ResultSet rs=my_SelMTStmt.executeQuery();

System.out.println("result set...");
while (rs.next())
{
System.out.println("inside 2 while");
int MT_amid=rs.getInt("automarkerid");
System.out.println("got automarkerid");
my_updateATPStmt.setInt(1,MT_amid);
System.out.println("set 1 done");
my_updateATPStmt.setString(2,dbsnpStr);
System.out.println("set 2 done");
my_updateATPStmt.executeQuery();
System.out.println("update done");
}
System.out.println("one update done !!!!");
my_updateATPStmt.executeQuery("commit");

}

my_updateATPStmt.executeQuery("commit");
my_updateStmt.close();
System.out.println("Update Allele temp done");
}
public static void main(String[] args)
{
try
{
AF_updateAlleleTmp up =new AF_updateAlleleTmp();
up.con();
up.updateAlleleTemp();
System.out.println("Hello World!");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}


after one update the i get the following error
java.sql.SQLException: ORA-01006: bind variable does not exist

can anyone plitz suggest something...
thanx
Aug 13 '07 #1
2 14162
madhoriya22
252 100+
hi
i am trying to update a table selecting a value from another table and ve written the following codes for it..

import java.sql.*;
import java.io.*;
import java.util.*;

public class AF_updateAlleleTmp
{
Connection m_alleleCon;

public void con() throws SQLException, java.lang.ClassNotFoundException
{
Class.forName("oracle.jdbc.driver.OracleDriver"); // oracle driver
m_alleleCon = (Connection)DriverManager.getConnection("jdbc:orac le:thin:@192.168.2.222:1521:SNPDB","g2p","g2p");

}

public void updateAlleleTemp() throws Exception
{
Statement my_updateStmt=m_alleleCon.createStatement(); //:1<int>,:2<char[32]>,:3<double>,:4<char[128]>)
PreparedStatement my_SelMTStmt=m_alleleCon.prepareStatement("select distinct(AutoMarkerID) from marker_temp where marker_temp.dbSNPrsID=?");
System.out.println("after 1");
PreparedStatement my_updateATPStmt=m_alleleCon.prepareStatement("upd ate allele_temp set allele_temp.AutoMarkerID =? where dbsnprsid=? and automarkerid is null");
System.out.println("after 2");
ResultSet AT_amid=my_updateStmt.executeQuery("select * from missingautomarkerid");
System.out.println("after 3");
while (AT_amid.next())
{

System.out.println("inside while");
String dbsnpStr=AT_amid.getString("dbsnprsid");
System.out.println("got dbsnprsid\t"+dbsnpStr);

my_SelMTStmt.setString(1,dbsnpStr);
System.out.println("sel stmt");
//ResultSet rs=my_SelMTStmt.executeQuery();

System.out.println("result set...");
while (rs.next())
{
System.out.println("inside 2 while");
int MT_amid=rs.getInt("automarkerid");
System.out.println("got automarkerid");
my_updateATPStmt.setInt(1,MT_amid);
System.out.println("set 1 done");
my_updateATPStmt.setString(2,dbsnpStr);
System.out.println("set 2 done");
my_updateATPStmt.executeQuery();
System.out.println("update done");
}
System.out.println("one update done !!!!");
my_updateATPStmt.executeQuery("commit");

}

my_updateATPStmt.executeQuery("commit");
my_updateStmt.close();
System.out.println("Update Allele temp done");
}
public static void main(String[] args)
{
try
{
AF_updateAlleleTmp up =new AF_updateAlleleTmp();
up.con();
up.updateAlleleTemp();
System.out.println("Hello World!");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}


after one update the i get the following error
java.sql.SQLException: ORA-01006: bind variable does not exist

can anyone plitz suggest something...
thanx
Hi,
For updating a table u should use pStatement.executeUpdate();

thanks and regards,
madhoriya22.
Aug 13 '07 #2
praveen2gupta
201 100+
Hi
1. In the second while loop you are using rs , ResultSet from which you are not getting any value. Use AT_amid.next() in place of rs.next().

2. In place of my_updateATPStmt.executeQuery(); use my_updateATPStmt.executeUpdate();

try and post your results and Explain your program working more clearly.
Aug 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: sumithradevi | last post by:
Hello Friends, I am getting the following error. java.sql.SQLException: ORA-00020: maximum number of processes (100) exceeded I am closing all my resultsets and all my connections in the try...
7
by: Jan Gregor | last post by:
Hello I found that jython catches exact java exceptions, not their subclasses. Is there some way to get around this limitation (or error) ? My program has class representing database source...
2
by: technocrat | last post by:
HOW CAN THIS BE DONE IN JAVA??? THIS IS POSITIONED UPDATE EXEC SQL DECLARE C1 CURSOR FOR SELECT * FROM EMPLOYEE FOR UPDATE OF JOB; EXEC SQL OPEN C1;
8
by: gimme_this_gimme_that | last post by:
I have the following Java code : package com.rhi.bb.udf.utils; import java.sql.Clob; import java.sql.SQLException; import java.util.regex.Pattern; import java.util.regex.Matcher;
4
by: eviewcs | last post by:
Hello I am a newbie in DB2. I am trying out the Mapping Java definitions to SQL on UDT from the article "DB2's object-relational highlights: Store and invoke structured type objects" by Kathryn...
2
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: ...
8
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive...
1
by: banging | last post by:
Hi there, I have a question regarding locking of tables so that when two or more people try to write or update the mysql tables, it locks up. Basically I only want one person to write to the...
2
by: dmstn | last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.