
ConnectionProvider.java import java.util.*; import java.io.*; import java.sql.*; class ConnectionProvider { static Properties prop; static { prop=new Properties(); try { prop.load(new FileInputStream("db.Properties")); }catch(Exception e) { System.out.println(e); } } public static Connection getConnection() { Connection con=null; try { Class.forName(prop.getProperty("driver class")); con=DriverManager.getConnection(prop.getProperty("url"),prop.getProperty("user"),prop.getProperty("password")); }catch(Exception e) { System.out.println(e); } return con; }
}
Selecttest1.java
import java.sql.*;
class SelectTest1
{
public static void main(String arr[])
{
try
{
Connection con=ConnectionProvider.getConnection();
System.out.println("name of Connection class is:"+con.getClass().getName());
Statement stmt=con.createStatement();
System.out.println("name of statement class is:"+stmt.getClass().getName());
ResultSet rset=stmt.executeQuery("select * from emp");
System.out.println("Name of resultset Class is:"+rset.getClass().getName());
System.out.println("following record are selected");
while(rset.next())
{
System.out.println(rset.getInt(1)+"\t"+rset.getString(2)+"\t"+rset.getString(3)+"\t"+rset.getInt(4));
}
}catch(Exception e)
{
System.out.println(e);
}
}
}
And db.properties Class
driver class=oracle.jdbc.driver.OracleDriver url=jdbc:oracle:thin:@localhost:1521:xe user=system pasword=oracle

It seems that problem lies in reading a properties file.
Go through the following link:
http://www.roseindia.net/tutorial/java/core/propertiesFile.html
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.