cjdbc常有异常总结

俾人在研究cjdbc 基本大部分的异常都碰到 要命 

没办法 只能拿着源码调试 才找到解决办法


1 ip地址配置错误

在控制文件中

  <Controller port="25322" ipAddress="192.168.3.149" backlogSize="11">

本人ip地址被封 换了159 所以这里没改 抛出这个异常 ipAddress必须是本机地址

2012-05-16 15:49:32,390 INFO  controller.core.Controller Starting JMX server on
host: 192.168.3.149
java.net.BindException: Cannot assign requested address: JVM_Bind
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(Unknown Source)
        at java.net.ServerSocket.bind(Unknown Source)
        at java.net.ServerSocket.<init>(Unknown Source)


2 数据库无法连接

配置的数据库信息:

 <DatabaseBackend name="db_153" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@192.168.3.122:1521:orcl11g" connectionTestStatement="select * from dual">
       <DatabaseSchema gatherSystemTables="false" schemaName="LIAOMIN" dynamicPrecision="table">
      </DatabaseSchema>
      <ConnectionManager vLogin="test" rLogin="liaomin" rPassword="liaomin">
      <RandomWaitPoolConnectionManager poolSize="40" timeout="30"/>
      </ConnectionManager>
    </DatabaseBackend>

无法连接会抛出以下异常


2012-05-16 15:56:11,468 WARN  controller.virtualdatabase.testDB Error while init
alizing database backend db_153 (java.sql.SQLException: Unable to connect to bac
kend.)
java.sql.SQLException: Unable to connect to backend.
        at org.objectweb.cjdbc.controller.backend.DatabaseBackend.checkDriverCom
pliance(DatabaseBackend.java:1546)
        at org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.getAnd
CheckBackend(VirtualDatabase.java:1409)
        at org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.forceE
nableBackend(VirtualDatabase.java:1048)
        at org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.enable
AllBackends(VirtualDatabase.java:1155)



3 收集 schema错误

这个错误是因为在oracle中必须要指定schema  而且schema  的名字必须为大写

<DatabaseBackend name="db_153" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@192.168.3.121:1521:orcl11g" connectionTestStatement="select * from dual">
<!--
       <DatabaseSchema gatherSystemTables="false" schemaName="LIAOMIN" dynamicPrecision="table">
      </DatabaseSchema>
-->
      <ConnectionManager vLogin="test" rLogin="liaomin" rPassword="liaomin">
      <RandomWaitPoolConnectionManager poolSize="40" timeout="30"/>
      </ConnectionManager>
    </DatabaseBackend>

将注释的打开就不抛出这个错误了 


2012-05-16 15:59:00,140 INFO  backend.DatabaseBackend.db_153 Gathering database
schema
2012-05-16 15:59:33,500 ERROR backend.DatabaseBackend.db_153 Runtime error while
 fetching schema
java.lang.NullPointerException
        at org.objectweb.cjdbc.common.sql.schema.DatabaseSQLMetaData.getPrimaryK
eys(DatabaseSQLMetaData.java:414)
        at org.objectweb.cjdbc.common.sql.schema.DatabaseSQLMetaData.createDatab
aseSchema(DatabaseSQLMetaData.java:149)
        at org.objectweb.cjdbc.controller.backend.DatabaseBackendMetaData.create
DatabaseSchemaDynamically(DatabaseBackendMetaData.java:899)
        at org.objectweb.cjdbc.controller.backend.DatabaseBackendMetaData.getDat
abaseSchema(DatabaseBackendMetaData.java:936)



4 创建恢复日志表错误

cjdbc默认给出的例子是hsql的

<RecoveryLog driver="org.hsqldb.jdbcDriver"
        url="jdbc:hsqldb:hsql://localhost:9003" login="TEST" password="">
        <RecoveryLogTable tableName="RECOVERY" idColumnType="BIGINT NOT NULL"
          vloginColumnType="VARCHAR NOT NULL" sqlColumnType="VARCHAR NOT NULL"
          extraStatementDefinition=",PRIMARY KEY (id)"/>
        <CheckpointTable tableName="CHECKPOINT"
          checkpointNameColumnType="VARCHAR NOT NULL"/>
        <BackendTable tableName="BACKEND"
          databaseNameColumnType="VARCHAR NOT NULL"
          backendNameColumnType="VARCHAR NOT NULL"
          checkpointNameColumnType="VARCHAR NOT NULL"/>
        <DumpTable tableName="DUMP" dumpNameColumnType="VARCHAR NOT NULL"
          dumpDateColumnType="VARCHAR NOT NULL"
          dumpPathColumnType="VARCHAR NOT NULL"
          dumpFormatColumnType="VARCHAR NOT NULL"
          checkpointNameColumnType="VARCHAR NOT NULL"
          backendNameColumnType="VARCHAR NOT NULL"
          tablesColumnType="VARCHAR NOT NULL"/>
      </RecoveryLog>

用于使用的oracle数据库   生成的创建表的sql就会出错 比如idColumnType="BIGINT NOT NULL"

BIGINT  在oracle中是没有这个数据类型的 这里给出oracle的正确的 我也配置了n久


 <RecoveryLog driver="oracle.jdbc.driver.OracleDriver"
        url="jdbc:oracle:thin:@192.168.3.153:1521:orcl" login="RECOVERYLOG" password="liaomin">
        <RecoveryLogTable tableName="RECOVERY_REAL" idColumnType="NUMBER NOT NULL PRIMARY KEY"
          vloginColumnType="VARCHAR2(2000) NOT NULL"  transactionIdColumnType="NUMBER NOT NULL" sqlColumnType="VARCHAR2(2000) NOT NULL"
          />
        <CheckpointTable tableName="CHECKPOINT_REAL"
          checkpointNameColumnType="VARCHAR2(2000) NOT NULL" requestIdColumnType="NUMBER" />
        <BackendTable tableName="BACKEND_REAL"
          databaseNameColumnType="VARCHAR2(2000) NOT NULL"
          backendNameColumnType="VARCHAR2(2000) NOT NULL"
          checkpointNameColumnType="VARCHAR2(2000) NOT NULL"/>
        <DumpTable tableName="DUMP_REAL" dumpNameColumnType="VARCHAR2(2000) NOT NULL"
          dumpDateColumnType="VARCHAR2(2000) NOT NULL"
          dumpPathColumnType="VARCHAR2(2000) NOT NULL"
          dumpFormatColumnType="VARCHAR2(2000) NOT NULL"
          checkpointNameColumnType="VARCHAR2(2000) NOT NULL"
          backendNameColumnType="VARCHAR2(2000) NOT NULL"
          tablesColumnType="VARCHAR2(2000) NOT NULL"/>
      </RecoveryLog>




java.lang.RuntimeException: Unable to initialize the database: java.sql.SQLException: Unable to create table RECOVERY_REAL (ORA-00902: 无效数据类型
)
at org.objectweb.cjdbc.controller.recoverylog.RecoveryLog.checkRecoveryLogTables(RecoveryLog.java:1976)
at org.objectweb.cjdbc.controller.xml.DatabasesParser.endElement(DatabasesParser.java:963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1528)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
at org.objectweb.cjdbc.controller.xml.DatabasesParser.readXML(DatabasesParser.java:268)
at org.objectweb.cjdbc.controller.xml.DatabasesParser.readXML(DatabasesParser.java:316)
at org.objectweb.cjdbc.controller.core.Controller.addVirtualDatabases(Controller.java:179)
at org.objectweb.cjdbc.controller.core.Controller.loadXmlConfiguration(Controller.java:529)
at org.objectweb.cjdbc.controller.core.ControllerFactory.setUpVirtualDatabase(ControllerFactory.java:408)
at org.objectweb.cjdbc.controller.xml.ControllerParser.configureVirtualDatabase(ControllerParser.java:668)
at org.objectweb.cjdbc.controller.xml.ControllerParser.startElement(ControllerParser.java:321)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1488)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
at org.objectweb.cjdbc.controller.xml.ControllerParser.readXML(ControllerParser.java:127)
at org.objectweb.cjdbc.controller.xml.ControllerParser.readXML(ControllerParser.java:177)
at org.objectweb.cjdbc.controller.xml.ControllerParser.readXML(ControllerParser.java:206)
at org.objectweb.cjdbc.controller.core.ControllerFactory.setUpByXml(ControllerFactory.java:250)
at org.objectweb.cjdbc.controller.core.ControllerFactory.setup(ControllerFactory.java:289)
at org.objectweb.cjdbc.controller.core.ControllerFactory.getController(ControllerFactory.java:315)
at org.objectweb.cjdbc.controller.core.Controller.main(Controller.java:716)
2012-05-16 16:06:33,078 WARN  controller.core.Controller The virtual database could not be added to the controller. (because of org.xml.sax.SAXException: Failed to check JDBC Recovery log tables.)
org.xml.sax.SAXException: Failed to check JDBC Recovery log tables.



5 oracle驱动没有放置到drivers目录


java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
        at org.objectweb.cjdbc.controller.connection.DriverClassLoader.findClass
(DriverClassLoader.java:115)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.objectweb.cjdbc.controller.connection.DriverManager.loadDriver(Dr
iverManager.java:284)
        at org.objectweb.cjdbc.controller.connection.DriverManager.getConnection
(DriverManager.java:147)
        at org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.g
etConnectionFromDriver(AbstractConnectionManager.java:196)
        at org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManag
er.initializeConnections(AbstractPoolConnectionManager.java:149)
        at org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManag
er.initializeConnections(AbstractPoolConnectionManager.java:119)
        at org.objectweb.cjdbc.controller.backend.DatabaseBackend.initializeConn
ections(DatabaseBackend.java:500)

posted @ 2012-05-16 15:48  饺子吃遍天  阅读(187)  评论(0编辑  收藏  举报