Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MaxDB - Everything about MaxDB, formerly known as SAP DB
MySQL++ - Programming with the C++ API to MySQL
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
mysql openssl Question
mysql:it 's a db not a dbms how it 's possible?!
Does the binary log enabling affect the MySQL performances?
Strange behavior, Table Level Permission
FULLTEXT query format question
Preventing Duplicate Entries
Comparing and writing out BLOBS
Executing MySQL Commands From Within C Program
Can 't access mysql after kernel upgrade
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Downgrade Mysql from 4 to 3 23
MySQL Cluster Software
mysql test 4 1 fails with the gis test
ERROR 2002: Can 't connect to local MySQL server through socket
Getting Identity after INSERT
Update one field with more fields from another table
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
mysql have same function mthod as Oracle decode()
 
exception when accessing maxdb via jdbc

exception when accessing maxdb via jdbc

2006-10-07       - By Zhang, Liang

 Back

Hi, All
i am using a simple program using jdbc to access the maxdb, the java code is
like below:
public class JdbcTest {

/**
 * @(protected) 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 liang.zhang@(protected)

SAP LABS CHINA: INNOVATE THE FUTURE