0
I tried to make the code below but it didn’t 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();
}
}
describes what exactly you mean by
não deu certo
– Math