1

Hello i got a Problem i alway get the same Error. In SQL itself it works but not in Java unfortunately

 java.sql.SQLSyntaxErrorException: ORA-00933: SQL-Befehl wurde nicht korrekt beendet

My Code:

 import java.sql.*; 
class verbindung2{ 
public static void main(String args[]){ 
try{ 
//step1 load the driver class 
Class.forName("oracle.jdbc.driver.OracleDriver"); 
//step2 create the connection object 
Connection con=DriverManager.getConnection( 
"jdbc:oracle:thin:@//pgbtf-cluster-test.company.de:1521/pgbtf.company.de","testuser","test123"); 
//step3 create the statement object 
Statement stmt=con.createStatement(); 
//step4 execute query 
ResultSet rs=stmt.executeQuery("select DOK_ID , ID, AKTEN_ID , TITEL , DOK_TYP , DOK_ART , ERSTELL_DAT , EING_DAT , DOK_MIME_TYPE from patgbmf.supi where DOK_MIME_TYPE='application/pdf' , OFFSET 20 ROWS FETCH NEXT 20 ROWS ONLY;"); 
while(rs.next()) 
System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)); 
//step5 close the connection object 
con.close(); 
}catch(Exception e){ System.out.println(e);} 
} 
} 
asked May 22, 2018 at 13:08
9
  • 2
    You have a comma before the OFFSET. Commented May 22, 2018 at 13:09
  • I removed it but i still get the same error Commented May 22, 2018 at 13:11
  • 3
    Is the ; creating problems? Commented May 22, 2018 at 13:14
  • Which version of oracle is that? 11? offset is not supported before 12 Commented May 22, 2018 at 13:14
  • @VeselinDavidov ok then it must be 12 or newer i can do it that statement in Oracle SQL Developer without problems Commented May 22, 2018 at 13:16

1 Answer 1

4

I had this problem too. This can be solved by removing the semicolon at the end of the query statement. The semicolon will be added automatically during execution and Oracle does not accept the resulting duplicate semicolon. check here

answered Jul 20, 2020 at 8:09
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.