Connecting java program to oracle databse

This code is working fine. here, in connection string test is the name of database, system is user and 123456 is password.
To run this program you need to use a jar file into classpath atteched here. that jar file may be found in oracle installation directory : oracle/jdbc/lib/

class OraDataBaseDemo1{
    public static void main(String ar[]){
            //loading driver
            //Here we are getting connection object
            Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:test","system","123456");
            //Statement object will be used to execute SQL queries
            Statement st=con.createStatement();
            String query="select * from address";
            ResultSet rs=st.executeQuery(query);
        }catch(Exception e){

No comments:

Popular Posts