Database connectivity issue in my code - java

Oracle JDBC Driver Registered!
The connection is established.
The statement object is created.
Exception in thread "main" java.sql.SQLException: ORA-00955: name is already used by an existing object
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:946)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1615)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1580)
at conn1.main(conn1.java:17)
I am having no error in the code but still, I'm not able to make a table.

ORA-00955 name is already used by an existing object.
The table name that you are trying to create by using you code also already exists so try with some other name

Related

Getting error "There is already an object named 'abc' in the database." even after keeping the hibernate.ddl-auto value to update

I am trying to boot up a spring boot application which connects to local ms-sqlserver (2019). I have already setup the db manually and kept the spring.jpa.hibernate.ddl-auto to update but still when application starts up it tries to create the table and throw an error. Application started but there was exception in console:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: There is already an object named 'abc' in the database.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1624)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:868)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:768)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7194)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2979)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:248)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:223)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:744)
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)
... 18 common frames omitted
I am not able to understand when I have set the hibernate property to update why it's not able to detect the existing table "abc".
Can anyone point out if I am doing anything wrong.

Spring Jdbc template Row mapper is not setting all values in Object

I am using spring jdbc template to retreive 400 records from oracle database.
After that i am using row mapper to convert rows to objects. Some of the values in object are not having any values. when i test same sql in pl/sql editor, i am able to see all rows and all columns for rows. When i debug application, i am getting below error. If i fetch less number of records(7) for same query, it is working fine.Row mapper is setting all values for object. Can you please help me on this.
java.sql.SQLException: statement handle not executed
2017-02-09 15:45:39 INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
2017-02-09 15:45:39 INFO SQLErrorCodesFactory:126 - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
2017-02-09 15:45:39 WARN SQLErrorCodesFactory:227 - Error while extracting database product name - falling back to empty error codes
org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Connection has already been closed.
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:305)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:329)
at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:214)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:134)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:97)
at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:645)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:680)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:707)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:757)
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:192)
If retrieving those 400 rows from the database take some time, I assume you are hitting DB connection timeout. If so, increase connectionTimeout if you are using resource pool. Timeout could happen while you are debugging the code, too.
Could also be that timeout is on the database side. In that case, you'll have to tweak DB timeout parameters.

Teradata createClob: function not supported in this version. Is this a bug or a feature?

I am trying to test createClob() method
String conStr = "jdbc:teradata://...";
Class.forName("com.teradata.jdbc.TeraDriver");
Connection conn = DriverManager.getConnection(conStr, "user", "pass");
Clob clobTest = conn.createClob();
However it throws the following error
Exception in thread "main" java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 15.00.00.20] [Error 165] [SQLState HY000] createClob: function not supported in this version
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:94)
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:69)
at com.teradata.jdbc.jdbc_4.TDSession.createClob(TDSession.java:1479)
I downloaded the latest version of jdbc
Why the error? What does it mean ?
The javadoc of createClob() says:
SQLException - if an object that implements the Blob interface can not be constructed, this method is called on a closed connection or a database access error occurs.
SQLFeatureNotSupportedException - if the JDBC driver does not support this data type
So technically this should have thrown a SQLFeatureNotSupportedException if Teradata does not support blobs, but that is just a minor 'bug'.
The only thing you can do is file an improvement request to ask them to implement this.

IO Exception: "/root/test outside /opt/h2/DB

currently I installed the H2 database, but when I the launch the program and I try to access it from my browser (http://localhost:8082/login.do), I get this error:
IO Exception: "/root/test outside /opt/h2/DB" [90028-192] 90028/90028 (Aide) org.h2.jdbc.JdbcSQLException: IO Exception: "/root/test outside /opt/h2/DB" [90028-192]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.engine.ConnectionInfo.setBaseDir(ConnectionInfo.java:182)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:114)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:102)
at org.h2.Driver.connect(Driver.java:72)
at org.h2.server.web.WebServer.getConnection(WebServer.java:735)
at org.h2.server.web.WebApp.login(WebApp.java:955)
at org.h2.server.web.WebApp.process(WebApp.java:211)
at org.h2.server.web.WebApp.processRequest(WebApp.java:170)
at org.h2.server.web.WebThread.process(WebThread.java:133)
at org.h2.server.web.WebThread.run(WebThread.java:89)
at java.lang.Thread.run(Thread.java:745)
How I can fixe this ?
Just add a single "." before the name of your database. For example this is the jdbc url for my database: jdbc:h2:tcp://localhost:9101/~/test and I'll change it to this to work: jdbc:h2:tcp://localhost:9101/~./test. I've read in a forum that this bug relates to H2.
you should change the form jdbc url
and the h2-data which is you start h2 server data path
jdbc:h2:/h2-data/test

MySql with database oracle.jdbc.pool.OracleDataSource

Is it possible to use MySql with oracle.jdbc.pool.OracleDataSource class?
I am trying to do that but getting an exception...
"Exception in thread "main" java.sql.SQLException: Invalid Oracle URL specified
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:301)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:221)"
where url is,
"String url = "jdbc:mysql://localhost:3306/test";"

Categories