我是新手,正在尝试将 android 应用程序连接到我的 oracle 数据库。我当前的代码抛出错误:
android.os.NetworkOnMainThreadException ...
我的连接代码如下:
public class ConnectOra {
public String driver, url, ip, bd, usr, pass;
public Connection conexion;
public ConnectOra(String ip, String bd, String usr, String pass) {
driver = "oracle.jdbc.driver.OracleDriver";
this.bd = bd;
this.usr = usr;
this.pass = pass;
url = new String("jdbc:oracle:thin:@" + ip + ":1521:" + bd);
try {
Class.forName(driver).newInstance();
conexion = DriverManager.getConnection(url, usr, pass);
// revisan el log para ver que tira....
System.out.println("Conexion a Base de Datos " + bd + " Exitosa");
} catch (Exception exc) {
System.out.println("Error al tratar de abrir la base de Datos "
+ bd + " : " + exc + "ricardo");
}
}
public Connection getConexion() {
return conexion;
}
public Connection CerrarConexion() throws SQLException {
conexion.close();
conexion = null;
return conexion;
}