I have this code but the Properties does have the method getProperty()
import java.io.*;
import java.sql.*;
import java.util.*;
public class TestCode {
static final String PROPERTY_FILE="JDBC-ODBC Driver.properties";
String driverName, url, user, password;
/** Creates a new instance of TestCode */
public void access() {
try{
/* Create an object of the Properties class and load properties. */
Properties prop=new Properties();
prop.load(new FileInputStream(PROPERTY_FILE));
driverName=prop.getProperty("driver"); // Retrieve driver information.
url=prop.getProperty("url"); // Retrieve JDBC URL.
user=prop.getProperty("user"); // Retrieve user name.
password=prop.getProperty("password"); // Retrieve password.
/* Initialize and load a driver. */
Class.forName("driverName");
/* Establish a connection with a database. */
Connection con=DriverManager.getConnection(url,user,password);
/* Create Statement object. */
Statement stmt=con.createStatement();
/* Executes a SQL query to retrieve a ResultSet. */
ResultSet rs=stmt.executeQuery("SELECT * FROM Registered_Users_Information");
/* Iterate through the ResultSet to display data. */
while(rs.next()){
System.out.println(rs.getString("UserName"));
System.out.println(rs.getString("Password"));
}
con.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
public static void main(String args[]){
TestCode t=new TestCode();
t.access();
}
}
Please show me the problem.
Thanks.
Nguyen_Tom