Bookmark Topic Watch Topic
  • New Topic

please help me to corect the error

 
nadeem akhtar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Report post to moderator
import java.sql.*;

public class Assignment{

public static void main ( String args[]){

try{

Class.forName("jdbc.odbc.JdbcOdbcDriver");

String url = "jdbcdbc:bankDSN";

Connection con= null;

con= DriverManager.getConnection(url,"","");


String sql = "SELECT * FROM Account";

PreparedStatement pStmt= con.prepateStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);



ResultSet rs = pStmt.executeQuery();

ResultSetMetaData rsmd = rs.getMetaData( );

int numColumns = rsmd.getColumnCount();

String cName;

for(int i =1; i<numColumns;i++)

{
cName = rsmd.getColumnName(i);
System.out.println(cName);
System.out.println("\t");

}

System.out.println(" ");
int AccountNo,AccountBal;
String ActHolderName,ActType;
while(rs.next( ))
{

AccountNo = rs.getInt(1);
ActHolderName= rs.getString(2);
ActType= rs.getString(3);
AccountBal= rs.getInt(4);


System.out.println(AccountNo);
System.out.println("\t");


System.out.println(ActHolderName);
System.out.println("\t");


System.out.println(ActType);
System.out.println("\t");


System.out.println(AccountBal);
System.out.println("\t");
System.out.println(" ");
}

con.close();
}catch(Exception sqlEx){
System.out.println(sqlEx);
}

}
}


 
Misha Ver
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please use a meaningful subject line - http://faq.javaranch.com/java/UseAMeaningfulSubjectLine and use code tags - http://faq.javaranch.com/java/UseCodeTags

Of course you should tell what is it "the error".
 
    Bookmark Topic Watch Topic
  • New Topic