Friday, November 9th, 2007
ResultSet myResultSet = null; public StatementBean() {super();} public String getPassword( String accountID ) throws Exception { String passwordOnDB = null ; String query = passwordQuery + accountID ; Statement stmt = myConn.createStatement(); myResultSet = stmt.executeQuery( query ); if ( myResultSet != null ) { myResultSet.next() ; passwordOnDB = myResultSet.getString( “password” ) ; myConn.takeDown() ; } return passwordOnDB ; } public boolean getAccountInfoQuery( String accountID ) throws Exception { String query = accountInfoQuery + accountID ; Statement stmt = myConn.createStatement(); myResultSet = stmt.executeQuery( query ); return (myResultSet != null); } public boolean get() throws Exception { return myResultSet.next(); } public String getColumn( String inCol) throws Exception { return myResultSet.getString(inCol); } } The StatementBean class contains code to perform the actual database connect through a superclass called SQLBean. The code for SQLBean is shown in Listing 10-6. Listing 10-6: Code for SQLBean.java package chapter10 ; import java.sql.*; import java.io.*; public class SQLBean{ private String myDriver = “sun.jdbc.odbc.JdbcOdbcDriver”; private String myURL = “jdbc:odbc:stock”; protected Connection myConn; public SQLBean() {} public void makeConnection() throws Exception { Class.forName( myDriver); myConn = DriverManager.getConnection(myURL); }
Our Colorado hosting facilities are located in Little Rock, Colorado. Colorado web hosting datacenter which we have is linked on five major US backbones which gives you assurance that your site will be online 24/7 a day. More details you can find out in Web Hosting Colorado part.