dbunit - SQL exception - java

I want to extract my database to FlatXmlDataSet. I use this tutorial:
http://www.dbunit.org/faq.html#extract
my code looks:
Class driverClass = Class.forName("oracle.jdbc.driver.OracleDriver");
Connection jdbcConnection = DriverManager.getConnection(
"jdbc:oracle:thin: <my parametres>", "<user>", "<password>");
IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
// full database export
IDataSet fullDataSet = connection.createDataSet();
FlatXmlDataSet.write(fullDataSet, new FileOutputStream("full.xml"));
and I have error:
Exception in thread "main" org.dbunit.dataset.DataSetException:java.sql.SQLSyntaxErrorException:
ORA-00942: table or view does not exist
at org.dbunit.database.DatabaseDataSet.getTable(DatabaseDataSet.java:316)
at org.dbunit.database.DatabaseTableIterator.getTable(DatabaseTableIterator.java:89)
at org.dbunit.dataset.stream.DataSetProducerAdapter.produce(DataSetProducerAdapter.java:83)
at org.dbunit.dataset.xml.FlatXmlWriter.write(FlatXmlWriter.java:124)
at org.dbunit.dataset.xml.FlatXmlDataSet.write(FlatXmlDataSet.java:341)
at db.main(db.java:26)
Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:195)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:876)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1175)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1296)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1498)
at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:406)
at org.dbunit.database.AbstractResultSetTable.<init>(AbstractResultSetTable.java:110)
at org.dbunit.database.ForwardOnlyResultSetTable.<init>(ForwardOnlyResultSetTable.java:59)
at org.dbunit.database.CachedResultSetTableFactory.createTable(CachedResultSetTableFactory.java:60)
at org.dbunit.database.DatabaseDataSet.getTable(DatabaseDataSet.java:312)
... 5 more
I use:
-eclipse
-dbunit 2.4.5
-slf4j 1.5.8
-maven 3.04
Thanks for any help

First of all, check if your connection parameters are correctly spelled, the necessary permissions are set and that the tables from your database really exist. You can then take a look at this similar post java.sql.SQLSyntaxErrorException: ORA-00942.

Related

How to resolve "IO-fout: Invalid connection string format, a valid format is: "host:port:sid"" error?

I am trying to make a DB connection to one of my DB. But it is throwing me error:
IO-fout: Invalid connection string format, a valid format is: "host:port:sid"
I am not getting any clue for this.
1.I upgraded my DB to 12c as per my project requirement
2.Updated from ojdbc14.jar to ojdbc6
3.Tried adding sid also but it is still giving the same error
url = "jdbc:oracle:thin:#abc";
DriverManager.registerDriver(new OracleDriver());
res =DriverManager.getConnection(url,userName,password);
Error:
java.sql.SQLRecoverableException: IO-fout: Invalid connection string format, a valid format is: "host:port:sid"
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:673)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:711)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:558)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)

Hibernate schema validation fails at Microsoft SQL Azure

I would like JPA application to validate schema during start. For this reason I added the following property to persistence.xml:
<property name="hibernate.hbm2ddl.auto" value="validate"/>
However hibernate fails to validate schema:
...
Caused by: org.hibernate.exception.SQLGrammarException: Error accessing table metadata
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.convertSQLException(InformationExtractorJdbcDatabaseMetaDataImpl.java:98)
at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getTables(InformationExtractorJdbcDatabaseMetaDataImpl.java:341)
at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.getTablesInformation(DatabaseInformationImpl.java:120)
at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:39)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:191)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:938)
... 41 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: USE statement is not supported to switch between databases. Use a new connection to connect to a different database.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:254)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:258)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:104)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:26)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$1ConnectionCommand.doExecute(SQLServerConnection.java:2907)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7240)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectionCommand(SQLServerConnection.java:2912)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.setCatalog(SQLServerConnection.java:3227)
at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.switchCatalogs(SQLServerDatabaseMetaData.java:342)
at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getResultSetFromStoredProc(SQLServerDatabaseMetaData.java:296)
at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getResultSetWithProvidedColumnNames(SQLServerDatabaseMetaData.java:318)
at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getTables(SQLServerDatabaseMetaData.java:502)
at org.apache.tomcat.dbcp.dbcp.DelegatingDatabaseMetaData.getTables(DelegatingDatabaseMetaData.java:604)
at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getTables(InformationExtractorJdbcDatabaseMetaDataImpl.java:329)
... 50 more
Is there any workaround except disable validation?
It's seems to there is syantx error in SQL file. Some time the SQL might get different from database to database, and the other another database not compitable for the sql syntax you using.

Exception in thread "main" java.sql.SQLException: ORA-20999: Invalid combination of paramters passed to procedure

I have a requirement where i have to handle optional parameters of procedure. I am able to execute it successfully by following
Invoking procedure defaults without binding values to parameters in Jdbc.
It works fine when i have all the parameters to procedure is IN parameter i.e., no registerOutParameter. if I am having OUT parameters and handling it, it is giving me error as below.
My current code
String getDBUSERCursorSql = "{call greetings (param_4 => ?,param_5 => ?, param_6 => ? , param_7 => ? )}";
Connection dbConnection = dataSource.getConnection();
callableStatement = dbConnection.prepareCall(getDBUSERCursorSql);
callableStatement.setString(1, "paramFoure");
callableStatement.setString(2,"paramSix");
callableStatement.setString(3,"paramSeven");
callableStatement.registerOutParameter(4, OracleTypes.CURSOR);
callableStatement.execute();
Exception in thread "main" java.sql.SQLException: ORA-20999: Invalid combination of paramters passed to procedure
ORA-06512: at "SYSTEM.GREETINGS", line 846
ORA-06512: at line 1
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:204)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1007)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3657)
at oracle.jdbc.driver.OracleCallableStatement.executeUpdate(OracleCallableStatement.java:4739)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350)

JasperReports JDBC TDS: internal error 2

I am trying to fill a jrxml file using JasperCompileManager and I am receiving the following error:
net.sf.jasperreports.engine.JRException: Error executing SQL statement for : MSWST
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:240)
at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1114)
at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:691)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1288)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:907)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:852)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:87)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
at net.sf.jasperreports.engine.JasperFillManager.fillToFile(JasperFillManager.java:228)
at net.sf.jasperreports.engine.JasperFillManager.fillToFile(JasperFillManager.java:124)
at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:666)
at DbReportFill.generateReport(DbReportFill.java:57)
at DbReportFill.main(DbReportFill.java:160)
Caused by: java.sql.SQLException: TDS: internal error 2
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2988)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2421)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:671)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:505)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:1029)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:233)
... 12 more
The connection looks like this:
connection = DriverManager.getConnection(
"jdbc:jtds:sybase://127.0.0.1:2631/serverName", "DBA",
"password");
I had heard that this may ocurre do to the driver, but i get the same error when I am using jconn3.

Oracle 11g: No more data to read from socket

I am encountering this error:
java.sql.SQLRecoverableException: No more data to read from socket
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1157)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:290)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:884)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1167)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1289)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)
We just upgraded our database from 10g to 11g w/o changing any connection parameters but encounters the error above.
Here are our connection url. Do I need to change anything?
username=test
password=test1234
url=jdbc:oracle:thin:#//localhost:1521/testDB
driver=oracle.jdbc.OracleDriver
dbName=OGG
timeout=60000
poolsize=1000
Thank you in advance.

Categories

Resources