• 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

My jdbc Program is not workin

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator







 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not working means?
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
I have added code tags which you should always use, and you can see how much better your code looks. On this forum (JDBC), please click the “Disable smilies in this message” box, so :o comes out as :o, not I have done that, too.
As Akhilesh Trivedi said, we can’t help unless we know the details.
 
Ganesh Bhaware
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Akhilesh Trivedi wrote:Not working means?


Sir its compile fine when be execute this code that time


D:\basics\jdbc>set classpath=C:\Users\Ganesh\Desktop\ojdbc14.jar;

D:\basics\jdbc>javac SelectQueryDemo2.java

D:\basics\jdbc>java SelectQueryDemo2
Enter table name
account
COnnected to oracle
java.sql.SQLException: Invalid column index: getValidColumnIndex
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:146)
at oracle.jdbc.driver.OracleResultSetMetaData.getValidColumnIndex(Oracle
ResultSetMetaData.java:143)
at oracle.jdbc.driver.OracleResultSetMetaData.getColumnName(OracleResult
SetMetaData.java:254)
at SelectQueryDemo2.main(SelectQueryDemo2.java:27)
 
Akhilesh Trivedi
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ganesh Bhaware wrote:

Akhilesh Trivedi wrote:Not working means?


Sir its compile fine when be execute this code that time


D:\basics\jdbc>set classpath=C:\Users\Ganesh\Desktop\ojdbc14.jar;

D:\basics\jdbc>javac SelectQueryDemo2.java

D:\basics\jdbc>java SelectQueryDemo2
Enter table name
account
COnnected to oracle
java.sql.SQLException: Invalid column index: getValidColumnIndex
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:146)
at oracle.jdbc.driver.OracleResultSetMetaData.getValidColumnIndex(Oracle
ResultSetMetaData.java:143)
at oracle.jdbc.driver.OracleResultSetMetaData.getColumnName(OracleResult
SetMetaData.java:254)
at SelectQueryDemo2.main(SelectQueryDemo2.java:27)



Check your line number 27 it is within loop. Is your for loop exceeding the values...?
 
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at this line of code:


As I remember, the index in JDBC is 1-based, not 0-based. So you may get exception when trying to access the 0th element.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic