• 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

unable to run the code.

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
unable to run this code and cant figure out why???
please help.new to JDBC

code compiles correctly but doesnt run properly

databsase structure
id ->number
name--> varchar
pwd -->varchar


try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:odbc:stud");
s = c.createStatement();

int b;





ResultSet rs=s.executeQuery("select * from abc");

ResultSetMetaData rsm=rs.getMetaData();

int col=rsm.getColumnCount();

while(rs.next())
{

for(b=1;b<=col;b++);
{
ta.append(rs.getString(b).trim()+ "\t\t");

}
ta.append("\n");
}






}
catch(Exception d)
{
d.printStackTrace();
}


}
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jigeshs Shahs wrote:unable to run this code and cant figure out why???
code compiles correctly but doesnt run properly


I didn't look at your code, because its not properly quoted using CODE tag.
And telling "it doesn't run properly" convey nothing, have a look at this for what I want to say.
ItDoesntWorkIsUseless
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read this. Tell us what happens, otherwise we can't help you.
 
Jigeshs Shahs
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the code compiles fine but throws a runtime exception.
it connects to the database properly...
the only problem I see here is when its extracts the data from ResultSetMetaData.
i ve marked that code "red" where its showing error...
so if anybody has any idea........please help
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately we can't see your desktop remotely, so you'll have to tell us the error message you're getting, complete with stack trace.
 
reply
    Bookmark Topic Watch Topic
  • New Topic