This question already has answers here:
Steps needed to use MySQL database with Play framework 2.0
(10 answers)
Closed 9 years ago.
There is my configure :
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql:root:play2test" //Cannot connect to database [default] -> play mark this line
db.default.user=root
db.default.pass=123456
I already created play2test.mwb with MySql-workbench, i have tried other way like :
db.default.driver="com.mysql.jdbc.Driver"
db.default.url="jdbc:mysql:root:play2test"
db.default.user="root"
db.default.pass="123456"
but allways get this error : db has type STRING rather than OBJECT
in terminal :
[error] c.j.b.h.AbstractConnectionHook - Failed to obtain initial connection Sleeping for 0ms and trying again. Attempts left: 0. Exception: null
[error] application -
! #6epj0nb4d - Internal server error, for request [GET /] ->
play.api.Configuration$$anon$1: Configuration error [Cannot connect to database [default]]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:71) ~[play_2.9.1.jar:2.0.4]
at play.api.Configuration.reportError(Configuration.scala:258) ~[play_2.9.1.jar:2.0.4]
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:249) ~[play_2.9.1.jar:2.0.4]
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:240) ~[play_2.9.1.jar:2.0.4]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.3]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.3]
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql:root:play2test
at java.sql.DriverManager.getConnection(DriverManager.java:640) ~[na:1.6.0_27]
at java.sql.DriverManager.getConnection(DriverManager.java:200) ~[na:1.6.0_27]
at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:256) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:305) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.BoneCPDataSource.maybeInit(BoneCPDataSource.java:150) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:112) ~[bonecp.jar:0.7.1.RELEASE]
I tried to uncomment at
ebean.default="models.*"
and added the sbt dependency:
"mysql" % "mysql-connector-java" % "5.1.21"
But it did'nt work :((((
So how can i solved it :(.
Sry if my english is bad
Try following way:
db.default.url="jdbc:mysql://your_server_address:3306/play2test"
db.default.driver="com.mysql.jdbc.Driver"
db.default.user=root
db.default.pass="123456"
db.default.host=your_server_address
Your connection url is formatted wrong. Try using:
db.default.url="jdbc:mysql://localhost/play2test"
And make sure you set the product dependency in /project/Build.scala, change the 5.1.25 to whatever version your mysql connector is
val appDependencies = Seq(
"mysql" % "mysql-connector-java" % "5.1.25"
)
And in the same file, make sure that this line is not commented
ebean.default="models.*"
The url should be something like:
db.default.url="jdbc:mysql://your_server_address/play2test"
Related
I'm trying to write a Java application for digitally signing documents using a bit4Id miniLector token.
I'm in a Linux development environment.
The token is correctly installed, I can sign my documents also with the app downloaded from the manufacturer, but I have to write a new one for other purposes. The driver used is located at
/usr/lib/x86_64-linux-gnu/engines-1.1/pkcs11.so
I'm stuck with this error:
/usr/lib/jvm/jdk1.8.0_111/bin/java ...
Exception in thread "main" java.security.ProviderException: Initialization failed
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:376)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:103)
at com.itextpdf.samples.signatures.chapter02.C2_01_SignHelloWorld.main
(C2_01_SignHelloWorld.java:83)
Caused by: java.io.IOException: ERROR: C_GetFunctionList == NULL
at sun.security.pkcs11.wrapper.PKCS11.connect(Native Method)
at sun.security.pkcs11.wrapper.PKCS11.<init>(PKCS11.java:138)
at sun.security.pkcs11.wrapper.PKCS11.getInstance(PKCS11.java:151)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:313)
... 2 more
The provider is listed in $JAVA_HOME/jre/lib/security/java.security file as:
security.provider.10=sun.security.pkcs11.SunPKCS11
The code behaving this way is this:
String configFile = "/opt/bar/cfg/pkcs11.cfg";
Provider provider = new sun.security.pkcs11.SunPKCS11(configFile); <-- line 83
The needed libraries are all imported by my IDE and I have no compile/link errors.
I didn't find this exact type of error in hours of googling.
If you need any further information let me know, any kind help is very appreciated, thanks.
For visual clarity I add all missing information with respect to the original question here below
Updates
Content of the pkcs11.cfg file:
$ cat /opt/bar/cfg/pkcs11.cfg
name="bit4id miniLector-EVO"
library=/usr/lib/x86_64-linux-gnu/engines-1.1/pkcs11.so
Ok, I got it.
The problem is the driver.
Replacing
/usr/lib/x86_64-linux-gnu/engines-1.1/pkcs11.so
with
/opt/Firma4NG/System/Firma4NG_Linux/Firma4/drivers/mu-x64/libbit4xpki.so
that is one of the manufacturer's driver, now I can go further and, for example, dumping all info about the card:
Information for provider SunPKCS11-bit4id miniLector-EVO
Library info:
cryptokiVersion: 2.20
manufacturerID: bit4id srl
flags: 0
libraryDescription: bit4id PKCS#11
libraryVersion: 1.02
...
This question can be closed.
In my project I am using jdbc to connect to a oracle 12c instance in a multi-threading environment, earlier we had an oracle 9i instance and we were using ojdbc6 and it was working perfectly but we receltly got this oracle 12c instance which gave following error at JDBC connection point.
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:774)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:39)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
So I thought it may be because of the older driver version that we had, so I incorporated ojdbc8 which I found over the internet to be compatible with 12 but the above error is still there. My JDK version is 1.8.
I'd appreciate any input on resolving this issue. Thanks in advance.
Sid. I think the bug occurred dut to the Oracle initialization parameter setting problem.
Please use the command line as below:
SQL > SHOW the PARAMETER of the SESSION
------------------------------------ ----------- ------------------------------
java_max_sessionspace_size integer 0
java_soft_sessionspace_limit integer 0
license_max_sessions integer 0
license_sessions_warning integer 0
session_cached_cursors integer 50
session_max_open_files integer 10
sessions integer 600
shared_server_sessions integer
the other command line:
SQL> SHOW PARAMETER PROCESS
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
aq_tm_processes integer 0
db_writer_processes integer 2
gcs_server_processes integer 2
global_txn_processes integer 1
job_queue_processes integer 1000
log_archive_max_processes integer 4
processes integer 150
According to the Oracle documentation, SESSIONS and the TRANSACTIONS of the initialization parameters should be derived from the PROCESSES, according to the default setting SESSIONS = 1.1 + 5 by the PROCESSES.
SESSIONS currently set up to 600, and the PROCESSES of setting has not changed, still for 150, led to too much user session to connect to the Oracle, Oracle do not have enough background PROCESSES to support these SESSIONS.
The direct solution is set the appropriate the PROCESSES.
I have a problem with the URL where I am trying to catch my DB.
Here is the code:
TransactionalGraph graph = new OrientGraph("/home/danicroque/Escritorio/demoCroque", "admin", "admin");
Here is the error:
run:
may 20, 2016 2:49:46 AM com.orientechnologies.common.log.OLogManager log
INFORMACIÓN: OrientDB auto-config DISKCACHE=907MB (heap=846MB os=3.802MB disk=447.700MB)
Exception in thread "main" com.orientechnologies.orient.core.exception.ODatabaseException: Error on opening database '/home/danicroque/Escritorio/demoCroque'
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:204)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:168)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.openOrCreate(OrientBaseGraph.java:1818)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.<init>(OrientBaseGraph.java:161)
at com.tinkerpop.blueprints.impls.orient.OrientTransactionalGraph.<init>(OrientTransactionalGraph.java:102)
at com.tinkerpop.blueprints.impls.orient.OrientTransactionalGraph.<init>(OrientTransactionalGraph.java:98)
at com.tinkerpop.blueprints.impls.orient.OrientGraph.<init>(OrientGraph.java:103)
at pruebatodook.PruebaTodoOk.run(PruebaTodoOk.java:23)
at pruebatodook.PruebaTodoOk.main(PruebaTodoOk.java:16)
Caused by: com.orientechnologies.orient.core.exception.OConfigurationException: Error in database URL: the engine was not specified. Syntax is: <engine>:<db-type>:<db-name>[?<db-param>=<db-value>[&]]*. URL was: /home/danicroque/Escritorio/demoCroque
at com.orientechnologies.orient.core.Orient.loadStorage(Orient.java:441)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:187)
... 8 more
may 20, 2016 2:49:46 AM com.orientechnologies.common.log.OLogManager log
INFORMACIÓN: OrientDB Engine shutdown complete
/home/danicroque/.cache/netbeans/8.1/executor-snippets/run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
I am trying to run this code in Ubuntu with Netbeans. The name of the DB is demoCroque and the URL is /home/Escritorio/demoCroque.
How can I solve this problem?
It looks like your URL is formed incorrectly.
See here: http://orientdb.com/docs/2.2/Console-Command-Connect.html
<database-url> Defines the URL of the database you want to connect to.
It uses the format <mode>:<path>
<mode> Defines the mode you want to use in connecting to the database.
It can be PLOCAL or REMOTE.
<path> Defines the path to the database.
Try something like this as your URL:
REMOTE:192.168.1.1/demoCroque
Or
PLOCAL:../home/Escritorio/demoCroque
Edit: for the purpose of testing use a full file path until you know it works correctly, for example:
PLOCAL:C:/projects/myproject/Escritorio/demoCroque
We have 10 Cassandra nodes in production running Cassandra-2.1.8. We recently upgraded to 2.1.8 version. Previously we were using only 3 nodes running Cassandra-2.1.2. First we upgraded the initial 3 nodes from 2.1.2 to 2.1.8 (following the procedure as described in Upgrading Cassandra). Then we added 7 more nodes running Cassandra-2.1.8 in cluster. Then we started our client programs. For first few hours everything worked fine, but after few hours, we saw some errors in client program logs like
Thread-0 [29/07/15 17:41:23.356] ERROR com.cleartrail.entityprofiling.engine.InterpretationWriter - Error:com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/172.50.33.161:9041, /172.50.33.162:9041, /172.50.33.95:9041, /172.50.33.96:9041, /172.50.33.165:9041, /172.50.33.166:9041, /172.50.33.163:9041, /172.50.33.164:9041, /172.50.33.42:9041, /172.50.33.167:9041] - use getErrors() for details)
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:65)
at com.datastax.driver.core.DefaultResultSetFuture.extractCauseFromExecutionException(DefaultResultSetFuture.java:259)
at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:175)
at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:52)
at com.cleartrail.entityprofiling.engine.InterpretationWriter.WriteInterpretation(InterpretationWriter.java:430)
at com.cleartrail.entityprofiling.engine.Profiler.buildProfile(Profiler.java:1042)
at com.cleartrail.messageconsumer.consumer.KafkaConsumer.run(KafkaConsumer.java:336)
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/172.50.33.161:9041, /172.50.33.162:9041, /172.50.33.95:9041, /172.50.33.96:9041, /172.50.33.165:9041, /172.50.33.166:9041, /172.50.33.163:9041, /172.50.33.164:9041, /172.50.33.42:9041, /172.50.33.167:9041] - use getErrors() for details)
at com.datastax.driver.core.RequestHandler.sendRequest(RequestHandler.java:102)
at com.datastax.driver.core.RequestHandler$1.run(RequestHandler.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Now, I double checked the Firewall (as suggested in few posts), ports, timeouts in client as well as nodes and they all are correct.
I am also not closing the connection anywhere in between. I am using batch queries with batch size of 1000 and the queries are update queries updating counters in my table with three columns
entity , twfwv , cvalue
where entity and twfwv columns are text and primary key and cvalue is counter column.
I even restarted all my nodes (because this trick helped me in my dev environment when I faced the same exception) but its not helping. Please suggest what can be the probable problem here.
My issue was resolved by checking the errors collection of NoHostAvailableException as advised by Olivier Michallat in the comments. For me it was the protocol version on the cluster configuration. Mine was null, setting it to 3 fixed the problem.
My issue was resolved by removing/using a property to set or unset the custom load balancing TokenAwarePolicy my connection was using, and relying on the default.
Specifically, I was trying to get a local spring boot app talking to a single dockerized Cassandra instance.
Cluster.Builder builder = Cluster.builder()
.addContactPoints(cassandraProperties.getHosts())
.withPort(cassandraProperties.getPort())
.withProtocolVersion(ProtocolVersion.V4)
.withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE))
.withCredentials(cassandraProperties.getUsername(), cassandraProperties.getPassword())
.withCodecRegistry(codecRegistry);
if (loadBalanced) {
builder.withLoadBalancingPolicy(
new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().withLocalDc(localDc).build()));
}
I am trying to use the Firebird embeded DB together with Hibernate, but I get the following error when trying to create the database:
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544344. I/O error during "CreateFile (open)" operation for file "D:\DB\FIREBIRD.FDB"
Error while trying to open file
null
at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:123)
at org.firebirdsql.jdbc.AbstractDriver.connect(AbstractDriver.java:126)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:204)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:292)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:214)
... 32 more
Caused by: org.firebirdsql.gds.GDSException: I/O error during "CreateFile (open)" operation for file "D:\DB\FIREBIRD.FDB"
Error while trying to open file
null
at org.firebirdsql.gds.impl.jni.JniGDSImpl.native_isc_attach_database(Native Method)
at org.firebirdsql.gds.impl.jni.BaseGDSImpl.iscAttachDatabase(BaseGDSImpl.java:158)
at org.firebirdsql.jca.FBManagedConnection.<init>(FBManagedConnection.java:105)
at org.firebirdsql.jca.FBManagedConnectionFactory.createManagedConnection(FBManagedConnectionFactory.java:490)
at org.firebirdsql.jca.FBStandAloneConnectionManager.allocateConnection(FBStandAloneConnectionManager.java:69)
at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:120)
... 36 more
What I have done until now:
I've set the hibernate configuration.
Driver = "org.firebirdsql.jdbc.FBDriver",
Dialect = "org.hibernate.dialect.FirebirdDialect",
Url = "jdbc:firebirdsql:embedded:D:\DB\FIREBIRD.FDB",
I have added the jaybird-full jar to my classpath.
I have added jaybird22.dll, fbembed.dll (the whole folder) to my path.
The dlls seem to be loaded since if I delete the dlls I get and exception telling me that jaybird22.dll cannot be found.
Any idea what could be wrong ?
It seems the step I was missing was creating the database file manually:
FBManager manager = new FBManager(GDSType.getType("EMBEDDED"));
manager.start();
manager.createDatabase(myDbFile, username, password);
manager.stop();