I'm trying to run a connection test in the bank and extract some information, just for the same study, however I'm running into the following error:
Exception in thread "main" java.sql.SQLException: ORA-00923: palavra-chave FROM não localizada onde esperada
How can I fix the error of this code and is there a simpler way to execute a select in the oracle database or is this enough code?
I want the query to show all the values in column 1 (ICCID) in the console.
packagePrincipal;importjava.sql.*;publicclassPrincipal{publicstaticvoidmain(String[]args)throwsException{Connectionconexao=ObterConexao();Statementstatement=conexao.createStatement();Stringquery="SELECT a.rp_package_value AS ICCID,"
+ "c.rrs_resource_value AS IMSI,"
+ "("
+ "CASE"
+ " WHEN (SUBSTR (c.rrs_resource_value, 6, 1) = SUBSTR (a.rp_package_value, 9, 1))"
+ "AND (SUBSTR (c.rrs_resource_value, 6, 2) <> '00')"
+ "THEN 'Valid'"
+ "ELSE 'Invalid'"
+ "END ) AS IMSI_CHECK ,"
+ "rrs_resource_sts Status, rp_package_sts"
+ "FROM mtaapp20.rm_packages a,"
+ "mtaapp20.rm_package_content b,"
+ "mtaapp20.rm_resource_stock c"
+ "WHERE a.rp_package_value IN"
+ "(SELECT RRS_RESOURCE_VALUE"
+ "FROM mtaapp20.rm_resource_stock c"
+ "WHERE c.rrs_resource_tp_id = 6"
+ "AND c.rrs_resource_pool = 30"
+ "AND SUBSTR (RRS_RESOURCE_VALUE, 9, 2) like '%1%' "
+ "AND c.rrs_resource_sts = 'ASSIGNED'"
+ ")"
+ "AND a.rp_package_id = b.rpc_package_id"
+ "AND c.rrs_resource_sts = a.rp_package_sts"
+ "AND b.rpc_component_tp_id = 5"
+ "AND b.rpc_component_vl_id = c.rrs_id"
+ "ORDER BY a.sys_creation_date DESC";
ResultSet resultSet = statement.executeQuery(query);
if (resultSet.next()) {
System.out.println(resultSet.getObject(2));
}
}
private static Connection ObterConexao() {
Connection conexao = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conexao = DriverManager.getConnection(
"jdbc:oracle:thin:@BRUX:1521:T00WM11", "USER", "SENHA");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conexao;
}
}