I've tried the code below but it did not work, I'm using Oracle 10g.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
public class AcessoBanco {
public static void main(String[] args) throws Exception{
String sql = "select id_usuario, nome_razao from usuario";
String url = "jdbc:oracle:thin:@localhost:1521:xe";
try(
Connection con = DriverManager.getConnection(url, "david", "5550123");
PreparedStatement stm = con.prepareStatement(sql);
ResultSet rs = stm.executeQuery()){
while(rs.next()){
System.out.println(rs.getString("nome_razao"));
}
}
// rs.close();
// stm.close();
// con.close();
}
}