Connecting Oracle to Play Framework 2.1.5 - oracle

I am still new in Play! Framework universe I i'd like to ask you folk a question. I am trying to connect Oracle to my application. Thus, I added this in the application.conf file:
db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.url="jdbc:oracle:thin:#localhost:1521/test"
db.default.user=scott
db.default.password="tiger"
And of course added the dependenies... But it still not working and throws me a beautiful exception :
"Configuration error : Cannot connect to database [default]"
Am I wrong in something ? Please I really need help.
Thanks.
#
#Frank Schmitt : nope I didn't tried this.
#wwkudu : by running my application, I get this :
[error] c.j.b.h.AbstractConnectionHook - Failed to obtain initial connection Sle
eping for 0ms and trying again. Attempts left: 0. Exception: null
[error] application -
! #6h70iggbo - Internal server error, for (GET) [/] ->
play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [
default]]
at play.api.Configuration$.play$api$Configuration$$configError(Configura
tion.scala:81) ~[play_2.10.jar:2.1.5]
at play.api.Configuration.reportError(Configuration.scala:559) ~[play_2.
10.jar:2.1.5]
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:251) ~[pla
y-jdbc_2.10.jar:2.1.5]
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:242) ~[pla
y-jdbc_2.10.jar:2.1.5]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike
.scala:244) ~[scala-library.jar:na]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike
.scala:244) ~[scala-library.jar:na]
Caused by: java.sql.SQLException: Exception d'E/S: Got minus one from a read cal
l
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:112) ~[ojdbc14-10.2.0.2.jar:Oracle JDBC Driver version - "10.2.0.1.0"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:146) ~[ojdbc14-10.2.0.2.jar:Oracle JDBC Driver version - "10.2.0.1.0"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:255) ~[ojdbc14-10.2.0.2.jar:Oracle JDBC Driver version - "10.2.0.1.0"]
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387) ~[ojdb
c14-10.2.0.2.jar:Oracle JDBC Driver version - "10.2.0.1.0"]
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
414) ~[ojdbc14-10.2.0.2.jar:Oracle JDBC Driver version - "10.2.0.1.0"]
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165) ~[ojd
bc14-10.2.0.2.jar:Oracle JDBC Driver version - "10.2.0.1.0"]

Check if the Database named test exists

Related

Is it possible to configure Presto with SpringJPA?

Based on the below error is see , Presto does not seem to be a valid dataSource that is compatible with Spring JPA
Description:
Failed to bind properties under 'spring.jpa.database' to org.springframework.orm.jpa.vendor.Database:
Property: spring.jpa.database
Value: presto
Origin: class path resource [application.yml]:101:22
Reason: failed to convert java.lang.String to org.springframework.orm.jpa.vendor.Database
Action: Update your application's configuration. The following values are valid: DB2 DEFAULT DERBY H2 HANA HSQL INFORMIX MYSQL ORACLE POSTGRESQL SQL_SERVER SYBASE
Thoughts or advise please ?

Setting up a database in glassfish server 4.1

As specified in oracle documentation I'm trying to setup a database in glassfish server. my JDK version is 1.8 and the glassfish is 4.1. I'm using the ojdbc7.jar.
I've put the ojdbc into \glassfish\domains\domain1\lib\ext folder and re-started both server and the database. But when I try to ping, an error comes as:
Ping Connection Pool failed for TestPool. Connection could not be allocated because: IO Error: The Network Adapter could not establish the connection
in server.log I found:
2015-04-13T18:35:25.413+0530] [glassfish 4.1] [WARNING] [test.connection.pool.failed] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors.service] [tid: _ThreadID=45 _ThreadName=admin-listener(2)] [timeMillis: 1428930325413] [levelValue: 900] [[
RAR8054: Exception while creating an unpooled [test] connection for pool [ TestPool ], Connection could not be allocated because: IO Error: The Network Adapter could not establish the connection]]
But I can ping "Derby Pool" which is in glassfish by default successfully. I've setup all the Connection pool properties and JVM options as mentioned in the documents.
Can someone please help to setup this correctly?
Thanks in Advance.
The driver seems to have problems connecting to the oracle instance.
Make sure you can make the connection from the glassfish to the oracle server. Especially check the hostname / port (the default oracle portnumber is 1521).
Here's a snapshot of my setup:
But while trying to ping, I found these on server log:
RAR8054: Exception while creating an unpooled [test] connection for pool [ TEST ], Connection could not be allocated because: IO Error: The Network Adapter could not establish the connection]]
Is this due to a server error, because I'm using glassfish 4.1.

JasperReports Server "The job failed to execute"

I am new to JasperReports Server and have searched for a resolve to this issue. I have found nothing. I inherited this server and the reports are not running as scheduled.
Job: 3rd (ID: 61)
Report unit: /reports/Scheduled/00_Schedule_Primer
Quartz Job: ReportJobs.job_61
Quartz Trigger: ReportJobs.trigger_62_1
Exceptions:
An error occurred while executing the report.
com.jaspersoft.jasperserver.api.JSException: jsexception.error.creating.connection
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcDataSourceService.createConnection(JdbcDataSourceService.java:62)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.BaseJdbcDataSource.setReportParameterValues(BaseJdbcDataSource.java:52)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcDataSourceService.setReportParameterValues(JdbcDataSourceService.java:67)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:743)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:367)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.executeReport(EngineServiceImpl.java:876)
at com.jaspersoft.jasperserver.api.engine.jasperreports.domain.impl.ReportUnitRequest.execute(ReportUnitRequest.java:60)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.execute(EngineServiceImpl.java:301)
at com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJob.executeReport(ReportExecutionJob.java:444)
at com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJob.executeAndSendReport(ReportExecutionJob.java:372)
at com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJob.execute(ReportExecutionJob.java:188)
at org.quartz.core.JobRunShell.run(JobRunShell.java:195)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
Caused by: java.sql.SQLException: Middleware connect fail:No RPC Connection active.
at com.ibm.u2.jdbc.UniJDBCMsgFactory.createException(UniJDBCMsgFactory.java:113)
at com.ibm.u2.jdbc.UniJDBCExceptionSupport.addAndThrowException(UniJDBCExceptionSupport.java:62)
at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.connect(UniJDBCProtocolU2Impl.java:746)
at com.ibm.u2.jdbc.UniJDBCProtocolU2Impl.executeOpenDatabase(UniJDBCProtocolU2Impl.java:243)
at com.ibm.u2.jdbc.UniJDBCConnectionImpl.<init>(UniJDBCConnectionImpl.java:116)
at com.ibm.u2.jdbc.UniJDBCDriver.connect(UniJDBCDriver.java:111)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:48)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:771)
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcDataSourceService.createConnection(JdbcDataSourceService.java:58)
... 12 more
I don't even have a clue where to start troubleshooting this. ANY help would be awesome!
It seems your connection url, username and password values are not proper.If these three things are proper then the connection will be created.Check in your Jasper server configuration.

How to access read-only Derby databases over a network client connection?

I'm trying to open a read-only Derby database over a network client connection (using ij / derbyclient.jar).
I have created a read-only database:
jar cMf sample.jar sample
The Derby Network Server is started.
I have tried the following connection URLs:
connect 'jdbc:derby:jar://localhost:1527/sample.jar';
connect 'jdbc:derby:jar://localhost:1527/(sample.jar)sample';
connect 'jdbc:derby://localhost:1527/jar:(sample.jar)sample';
But none of the above URLs work.
The only URL that works is:
connect 'jdbc:derby:jar:(sample.jar)sample';
It appears that read-only Derby databases can only be opened in embedded mode. Is this true ?
Solved:
After checking the "derby.log", the problem was that the read-only database needs to be able to create a temporary file.
derby.log:
java.sql.SQLException: Failed to start database 'jar:(sample.jar)sample' with class loader sun.misc.Launcher$AppClassLoader#1d450337, see the next exception for details.
...
Caused by: java.sql.SQLException: Failed to start database 'jar:(sample.jar)sample' with class loader sun.misc.Launcher$AppClassLoader#1d450337, see the next exception for details.
...
Caused by: java.sql.SQLException: Java exception: 'Unable to create temporary file: java.lang.SecurityException'.
...
Caused by: java.lang.SecurityException: Unable to create temporary file
The solution is to define a temporary directory for the database. This can be done with the "derby.storage.tempDirectory" property:
System-wide in "derby.properties":
derby.storage.tempDirectory=c:/temp
Database-wide
CallableStatement cs =
conn.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)");
cs.setString(1, "derby.storage.tempDirectory");
cs.setString(2, "c:/temp");
cs.execute();
cs.close();
The network URL is:
connect 'jdbc:derby://localhost:1527/jar:(sample.jar)sample';

table or view does not exist when play2 accesses oracle

everyone. I use hibernate jpa in play2.0. First I use H2 and it goes well. Then I use oracle instead, and the jpa create tables for me correctly. But when I send any request to play, it report errors:
[info] play - datasource [jdbc:oracle:thin:#58.215.201.110:1521:orcl2167] bound
to JNDI as DefaultDS
[info] play - database [default] connected at jdbc:oracle:thin:#58.215.201.110:1
521:orcl2167
[warn] application - play_evolutions table already existed
[error] application -
! #6b43j2ce2 - Internal server error, for request [GET /] ->
play.api.UnexpectedException: Unexpected exception [sqlexception ora-00942 table or view does not exist]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3$$anon
fun$1.apply(ApplicationProvider.scala:134) ~[play_2.9.1.jar:2.0]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3$$anon
fun$1.apply(ApplicationProvider.scala:112) ~[play_2.9.1.jar:2.0]
at scala.Option.map(Option.scala:133) ~[scala-library.jar:0.11.2]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3.apply
(ApplicationProvider.scala:112) ~[play_2.9.1.jar:2.0]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3.apply
(ApplicationProvider.scala:110) ~[play_2.9.1.jar:2.0]
at scala.Either$RightProjection.flatMap(Either.scala:277) ~[scala-librar
y.jar:0.11.2]
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:111) ~[classes12.jar:Oracle JDBC Driver version - "10.2.0.1.0"]
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:330) ~[class
es12.jar:Oracle JDBC Driver version - "10.2.0.1.0"]
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:287) ~[class
es12.jar:Oracle JDBC Driver version - "10.2.0.1.0"]
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:742) ~[classes12.ja
r:Oracle JDBC Driver version - "10.2.0.1.0"]
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:206) ~[clas
ses12.jar:Oracle JDBC Driver version - "10.2.0.1.0"]
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:
789) ~[classes12.jar:Oracle JDBC Driver version - "10.2.0.1.0"]
Try connecting to the database and verify the table does exist(readonly).
In your application.conf file do something like,
evolution=disabled.

Resources