There's very little information about DbSetup so I couldn't find an answer to this question anywhere else.
I need to test Data Access Layer and decided to use DbSetup for it. I tried to use DbSetup user guide this example just to see how it works but I get such exception:
com.ninja_squad.dbsetup.DbSetupRuntimeException: java.sql.SQLException: No suitable driver found for 127.0.0.1:3306
My database is MySQL Server.
What could be the problem?
Your URL is incorrect. JDBC URL for MySQL looks like
jdbc:mysql://localhost:3306/databasename
as described in the documentation.
And of course, the jar of the MySQL JDBC driver must be in the classpath.
Related
I'm really looking for and advice on how to set up data streaming between Oracle db (just for example) and Clickhouse database using Airbyte ETL tool.
I've created the source and destination connectors and successfuly tested the connections but now I'm facing the issue in syncing the data. While the source is sending the data correctly, the destination (Clickhouse) JDBC driver requires the schema to accept those tables.
So, I don't know how to retrieve this schema and where it should be stored. Maybe there're some means to create this schema, because when I inspect the log it displays such thing:
So, basically, the error is connected with Exception in thread "main" java.lang.IllegalStateException: jdbc destinations must specify a schema.
Please I will be really grateful for providing any means for resolving that issue!
I think use should try version 0.1.1 of ClickHouse destination. It fixes your issue https://github.com/airbytehq/airbyte/pull/8982
I am surprised I haven't found an SO question that answers this. I am trying to connect a springboot/JPA application to an SQL Server on my local machine. I have the application setup so that it can connect to a database if it it exists, but if I change the JDBC URL to create the database if it doesn't exist then it fails. Here is what the properties look like when it fails.
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=testing;createDatabaseIfNotExist=true;
spring.datasource.username=hello
spring.datasource.password=Hello1234
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.database-platform=org.hibernate.dialect.SQLServer2008Dialect
spring.jpa.show-sql=true
Here is a snippet of the error I receive when starting the app:
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user
'hello'. ClientConnectionId:971a3369-258b-4713-bddc-cda559b9fe94 at
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
~[mssql-jdbc-8.4.0.jre11.jar:na] at
com.microsoft.sqlserver.jdbc.TDSTokenHandle
If anybody has any thoughts as to how I can change this so the database is created if it does not exist I would be very thankful. Thanks in advnace.
I don't think a database can be created using JPA.
It has to be created manually or in some other ways, but JPA won't do that for you.
And it would be a bad practice as well to create the database using the application itself, and the use of same credentials.
Yes, definitely you can auto-create a database with JPA for that
spring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=testing;
createDatabaseIfNotExist=true;
line should be changed to:
spring.datasource.url=jdbc:sqlserver://localhost:1433
/testing?createDatabaseIfNotExist=true
In practice your application should never create your database so its not really a problem most of the time(Outside small databases like sqlite3). Different databases would handle this situation differently as well.
In your case I do not see this as a valid jdbc parameter in the documentation.
I would recommend creating the database in advance with a privileged user separate from your application user.
Was wondering, what steps am I missing to get a jdbc embeded h2 database working in my play application? Following these docs.
So far editted Application.conf file to contain this:
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:databases/test"
db.default.user=test
db.default.password="testtest"
Next I created a libs directory and added the jar file
h2-1.3.174.jar
Is this necessary or does the provided driver handle all types of h2 databases (embeded and server - I know it handles in memory)?
Now in the controler how can I access the database? Do I have to start/shutdown the database?
I know I can get connections from the getConnection() method in play.db. But everytime I execute a statement through this connection I get an exception saying no data is available. If I then check - looks like directory
databases/test
was not created so no database files exist.
What am I missing?
H2 works out of the box. Just create a new project in the terminal.
Otherwise, to your listing:
I think you should change db.default.url="jdbc:h2:databases/test" to db.default.url="jdbc:h2:mem:play"
don't need to create lib directories. It's all handeled by the build in dependency mgmt sbt
Just use the model objects and call save/update. No need to call start/shutdown
you are in a framework, it's all there ready for you...
I think you should start reading the documentation from the beginning to the end and examine the example applications. It's all there what you are looking for.
In addition to myborobudur's answer I'll only mention, that you don't need to use memory database, as you can for an instance use file storage (Embedded) or even run H2 as a server and then connect to it with TCP in Server Mode... Everything is clearly described in H2 documentation.
I try to use Glassfish/MySQL. I have created JDBC resource and JDBC connection pool for MySQL.
But if I tried to put MySQL JDBC resource in jta-data-source, nothing works.
Then if I tried to modify jdbc/__default and change its connection pool from DerbyPool to MySQL, it works. My entity gets persists to the correct table.
So do I have to use jdbc/__default only as my JDBC resource for my app? How can I use the JDBC resource and JDBC connection pool I created in my app?
I really have hard time understanding how to use JDBC in Glassfish.
This is my first time to ask question in this forum. Thank you very much.
See this link for a step by step tutorial on how to create JDBC connection pools in Glassfish server. Here is the official documentation on how to do it. Or you can read this SO question. And another resource that you can use is this SO question.
Using the embedded driver I can connect to my derby database using the JDBC url:
jdbc:derby:mydbname
But, I usually put the full path for the db like:
jdbc:derby:/Users/oreyes/dbs/mydbname
Is there a way I can just specify the db name and have something like a "db_path" or something like that?
I'm not an expert with derby, setting derby.system.home as described in developers guide seems to work as you expect.