This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
    Bookmark Topic Watch Topic
  • New Topic

I FACE SOME ERROR, PLEASE HELP ME, ALSO I SEE THE RESULT IN SIMPLE GUI

 
nadeem akhtar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Report post to moderator
//PLEASE CORRECT THE ERROR AND I WANT TO SEE QUERY RESULT IN SIMPLE GUI WINDOW. PLASE GIVE ME THE SOME HINT

import java.sql.*;

public class Assignment{

public static void main ( String args[]){

try{

Class.forName("sun.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);
}

}
}


 
    Bookmark Topic Watch Topic
  • New Topic