Hi, All
i am using a simple program using jdbc to access the maxdb, the java code is 
like below:
public class JdbcTest {
 
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  
  Connection conn = getConnection("10.56.72.140", "7210", "SBS", "DBA", "DBA");
 
  Statement stmt = null;
  String sql = "SELECT TOP 10 * FROM \"TEST\".\"TestTable\" ORDER BY \"TestID\" 
ASC ";
  ResultSet rs = null;
  
  try {
   stmt = conn.createStatement();
   rs = stmt.executeQuery(sql);
   conn.commit();
   while(rs.next()){// exception got here: 
com.sap.dbtech.jdbc.exceptions.DatabaseException: [-108]: Table or index 
dropped or content deleted
    System.out.println("CompanyDB: " + rs.getString(2));
   }
   conn.close();
  } catch (SQLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  
  
 }
 
 public static Connection getConnection(String dbServer, String port, String 
dbName,
   String userName, String password){
  try {
   String dbdriver = "com.sap.dbtech.jdbc.DriverSapDB"; //get db driver
   Class.forName(dbdriver);
   String urlPattern = "jdbc:sapdb://%dbserver%:%port%/%db%";
   String url = urlPattern.replaceFirst(
     "%dbserver%", dbServer).replaceFirst(
       "%port%", port).replaceFirst(
     "%db%", dbName);
 
   Connection conn = null;
 
   conn = DriverManager.getConnection(url, userName, password);
   
   conn.setAutoCommit(false);
   conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
 
   return conn;
  } catch (ClassNotFoundException ex) {
   ex.printStackTrace();
  } catch (SQLException ex) {
   ex.printStackTrace();
  }
  return null;
 }
 
}
 
if i remove the "top 10" clause, it will succeed, but i need the clause(the 
"Limit 10" clause will also cause the exception).
and if i execute the sql in sqlstudio, i can get the right result

 i have no idea why this exception happens, can anyone help me with it, thx 
very much

Best regards

Liang Zhang

Developer
SAP Labs China 

T: +86 21 61006699-7775 
F: +86 21 50807498 
Email [EMAIL PROTECTED] 

SAP LABS CHINA: INNOVATE THE FUTURE 

 

Reply via email to