• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.sql.SQLException: Invalid column index

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am reading columns from a table... but it gives java.sql.SQLException: Invalid column index runtime sql exception

InputStream in = null;
OutputStream out = null;

Statement statement = null;
ResultSet resultSetone1 = null,resultSettwo = null;
Acd acd =new Acd();
try {
// Check arguments

out = new FileOutputStream("D://SimpleEx//acd.txt");

connection = acd.getOracleConnection();

statement = connection.createStatement ();
//String sQueryone = "select tcd.call_ref_no,tcd.lanfaxid,tcd.resolved, tcd.curr_status, tcd.group_code from FORESEE.t_call_details tcd where tcd.call_ref_no in (select tc.call_ref_no from FORESEE.t_call tc where tc.start_datetime between TO_DATE('"+maxTime+"','MM/DD/YYYY HH24:MI:SS')and sysdate)";;
String sQueryone = "SELECT expirydate FROM acdtds.elecsubscription WHERE expirydate >= sysdate";

System.out.println("1 Querying....." + sQueryone);

resultSetone1 = statement.executeQuery(sQueryone);
int count1 = 0;
while (resultSetone1.next())
{
out.write(resultSetone1.getBytes(0));
out.write(',');
}
}
// On exceptions, print error message and usage message
catch (Exception e) {
System.err.println(e);
System.err.println("Usage: getURL []");
}
finally { // Always close the streams, no matter what.
try {
in.close();
out.close();
}
catch (Exception e) {}
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why have you defined a field called "expirydate" using a binary datatype? Would it not be better to define it as a date or timestamp and call a rs.getDate() method to get its value?
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Satish Nalam:

java.sql.SQLException: Invalid column index runtime sql exception




Welcome to Javaranch Satish Nalam,

SQLException is already given you answered of your error.
you defined column index by 0 in your above code..

hope it helps..
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic