用JDBC连接Oracle

 

public class ConnectToOracle{

Pubic static void main(Stirng []args){

  try{

        Class.forName(oracle.jdbc.driver.OracleDriver);

        Connection conn=DriverManager.getConnection (“jdbc:oracle:thin:@127.0.0.1:1521:feinar”, “feinar”, “feinardev” );

        String sql = “select * from table1”;

        PreparedStatement ps = conn.prepareStatement(sql);

        ResultSet rs = ps.executeQuery();

        While(rs.next()){

            System.out.println(rs.getString(1)+’/t’);

}

}catch(Exception e){

      e.printStackTrace();

}

}

}

你可能感兴趣的:(Oracle,JDBC,SQL,C,C++)