Hallo,
ich versuche aus einer Java-Applikation ein ganz normales SQL-Statement auf Oracle-DB auszuführen und zwar:
public ResultSet getCountries(Connection connection)
{
ResultSet res = null;
//mein SQL-Statement:
String sql = "SELECT * FROM Regionen ORDER BY "+Country.COLUMN_REGIONSID+" ASC;";
try {
res = getResult(connection, sql);
}
catch (SQLException e) {
//ICH LANDE IMMER HIER
System.out.println("Error on execute sql statement. " + e);
}
return res;
}
private ResultSet getResult(Connection connection, String sql) throws SQLException
{
ResultSet res = null;
if (connection != null)
{
Statement statement = connection.createStatement();
if (statement.execute(sql)) //GENAU HIER KRACHTS
{
res = statement.executeQuery(sql);
}
}
else
throw new SQLException("No Database connection available!");
return res;
}
in der catch-Anweisung von getCountries() lande ich immer mit der Fehlermeldung:
Error on execute sql statement. java.sql.SQLException: ORA-00911: Ungültiges Zeichen
Das SQL-Statement an sich ist richtig (habe den im Oracle SQL Developer getestet und richtige Ergebnismenge bekommen)
Kann mir da jemand auf meinen Fehler hinweisen?
Danke
ich versuche aus einer Java-Applikation ein ganz normales SQL-Statement auf Oracle-DB auszuführen und zwar:
public ResultSet getCountries(Connection connection)
{
ResultSet res = null;
//mein SQL-Statement:
String sql = "SELECT * FROM Regionen ORDER BY "+Country.COLUMN_REGIONSID+" ASC;";
try {
res = getResult(connection, sql);
}
catch (SQLException e) {
//ICH LANDE IMMER HIER
System.out.println("Error on execute sql statement. " + e);
}
return res;
}
private ResultSet getResult(Connection connection, String sql) throws SQLException
{
ResultSet res = null;
if (connection != null)
{
Statement statement = connection.createStatement();
if (statement.execute(sql)) //GENAU HIER KRACHTS
{
res = statement.executeQuery(sql);
}
}
else
throw new SQLException("No Database connection available!");
return res;
}
in der catch-Anweisung von getCountries() lande ich immer mit der Fehlermeldung:
Error on execute sql statement. java.sql.SQLException: ORA-00911: Ungültiges Zeichen
Das SQL-Statement an sich ist richtig (habe den im Oracle SQL Developer getestet und richtige Ergebnismenge bekommen)
Kann mir da jemand auf meinen Fehler hinweisen?
Danke