I've seen the project via developpez.com
https://www.developpez.com/actu/118014/Cloud-Spanner-Google-lance-pour-le-grand-public-sa-solution-de-bases-de-donnees-globales-offrant-un-bon-compromis-entre-SQL-et-NoSQL/
CockroachDB seems to supports ACID transactions. So my question is:
Is it possible to use it with JPA and JTA?
CockroachDB is compatible with the JDBC API, via the Postgres pgjdbc driver. Since JPA and JTA connect to databases via JDBC, they should be useable against CockroachDB as long as you use the pgjdbc driver.
If you're using Maven, you can add the following declaration to your pom.xml to add a dependency on pgjdbc:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>VERSION</version>
</dependency>
Replace VERSION with a driver version selected from the list in Maven central.
Related
I want my Quarkus app to connect to both a PostgreSQL database and a MySQL database.
I've researched through https://quarkus.io/guides/datasource#multiple-datasources and https://quarkus.io/guides/hibernate-orm#multitenancy, but could not figure out if this is possible.
my application.properties is as below;
quarkus.datasource.postgresql.db-kind=postgresql
quarkus.datasource.postgresql.username=xyz
quarkus.datasource.postgresql.password=xyz
quarkus.datasource.postgresql.jdbc.url=jdbc:postgresql://localhost:5432/xyz
quarkus.datasource.mysql.db-kind=mysql
quarkus.datasource.mysql.username=xyz
quarkus.datasource.mysql.password=xyz
quarkus.datasource.mysql.jdbc.url=jdbc:mysql://localhost:3305/xyz
my pom.xml has both;
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mysql</artifactId>
</dependency>
Is it possible to connect to multiple different types of database from Quarkus?
How do I persist() an Entity to the correct database if such capability exists?
Thank you!
What you are asking for is supported, see this part of the datasource documentation and this part of the Hibernate ORM documentation.
I have a legacy app that is currently working with Postgres9 that I have to migrate to postgres12.
I did the dump the old database and restored it to the new one without issues.
But when I tried to connect my legacy app with the new database the app never connects.
In the past, my POM was:
<!-- Postgresql Database Support -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1211.jre7</version>
</dependency>
and now (after checking that the old version was not working I tried to did some update here):
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>
In my properties I have:
jdbc.driver=org.postgresql.Driver
jdbc.url=jdbc:postgresql://XXXXXXXXXXXXXXXXXXXXXXxxxx:XXXX/db_name
jdbc.username=db_user
jdbc.password=xxxxx
Before I was using a postgres installed in a server, but now, I'm using a Database for postgres from IBM Cloud (I supossed this should not generate any issue). Similar to RDS from AWS.
So when I tried to run my app I got tomcat timeout. I increased the timeout to 120 but I'm still getting that error...
Exactly same configuration on Dbeaver works like a charm.
I tried with that version of the driver but same behavior (the one for org.postgres)
I am implementing a program in Spring-Boot using ObjectDB. To actually use ObjectDB I have followed this approach which is working perfectly.
However, as soon as I want to use `spring-boot-starter-web`` then I am getting the following errors:
dataSource or dataSourceClassName or jdbcUrl is required. at
com.zaxxer.hikari.HikariConfig.validate
I have been fiddling around with parameter jdbc-url in the properties file as mentioned in many posts. Tried to exclude Hikari because probably ObjectDB uses his own connection pooling mechanism. But without any results.
Any ideas on how to solve this error?
I am using the exact same code as in the link. I have added Spring-Actuator in the pom like this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
In some cases, frameworks that use JPA require specifying a JDBC connection details, including a JDBC driver, which is then passed to the JPA implementation and used by it to access the database. ObjectDB is a JPA implementation that does not access an external database, and therefore, does not need or use a JDBC driver.
As discussed in the comments to the question, a simple workaround is to specify a dummy JDBC driver, which will be passed to ObjectDB and then ignored. It does look weird, but this is the way to go until either ObjectDB implement its own JDBC driver, or the relevant frameworks become more flexible regarding their request of a JDBC driver.
Have you tried this (in the pom.xml?):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.objectdb</groupId>
<artifactId>objectdb</artifactId>
<version>2.8.4</version>
</dependency>
And don't forget to add the database connection in application.properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=mydbuser
spring.datasource.password=mydbpass
spring.datasource.url=jdbc:....
See https://www.baeldung.com/the-persistence-layer-with-spring-and-jpa for more details.
Is it possible to connect to an embedded Neo4j database the same way you would do with an H2 in-memory database to mock an Oracle database?
I've tried to do this:
final BoltConnector boltConnector = new BoltConnector("bolt");
graphDb = new GraphDatabaseFactory()
.newEmbeddedDatabaseBuilder(DB_PATH)
.setConfig(boltConnector.type, BOLT.name())
.setConfig(boltConnector.enabled, TRUE)
.setConfig(boltConnector.listen_address, listenAddress("127.0.0.1", 7688))
.setConfig(boltConnector.encryption_level, DISABLED.name())
.setConfig(GraphDatabaseSettings.auth_enabled, FALSE)
.newGraphDatabase();
And then make a request using the JDBC Bolt driver with the following spring.datasource configuration:
spring:
profiles: test
datasource:
driver-class-name: org.neo4j.jdbc.bolt.BoltDriver
url: jdbc:neo4j:bolt://127.0.0.1:7688/?nossl
But I always get the following error:
Unable to connect to 127.0.0.1:7688, ensure the database is running and that there is a working network connection to it.
Of course the embedded database works when I use the graphDb instance and execute requests against it. But I want my application to connect to the embedded database as it does when connecting to a remote Neo4j database.
This is for testing purpose.
I finally RTFM...
I had the following dependency in my pom.xml:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>3.4.0</version>
</dependency>
Then I found this: https://neo4j.com/docs/java-reference/current/tutorials-java-embedded/#tutorials-java-embedded-bolt
The documentation is a bit outdated because it uses deprecated configuration. But they explain this:
The Neo4j Browser and the official Neo4j Drivers use the Bolt database
protocol to communicate with Neo4j. By default, Neo4j Embedded does
not expose a Bolt connector, but you can enable one. Doing so allows
you to connect the services Neo4j Browser to your embedded instance.
And they make clear the correct dependency to use is:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-bolt</artifactId>
<version>3.4.0</version>
</dependency>
I created a spring-boot project to read and write data to Sybase database. The project was working as intended. However, whenever I added activiti dependencies, It says "couldn't deduct database type from database product name 'Adaptive Server Enterprise'". According to my understanding, there are some classes conflicting each other in activiti and spring even though I do not use anything regarding activiti( except the fact that I just opened a folder called processes in the resources directory).
The activiti dependencies I added are:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>5.21.0</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-rest-api</artifactId>
<version>5.21.0</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-actuator</artifactId>
<version>5.21.0</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-jpa</artifactId>
<version>5.21.0</version>
</dependency>
To clarify my point in this, I wanted to use activiti just for workflow purposes and leave the rest of the ETL or database job to spring. If I change database from Sybase to Mysql, the project also works fine even with activiti dependencies. As far as I know activiti has no support for Sybase and apparently, it tries to interfere everything possible and overrides something that was already working at the first place. How can I overcome this problem?
you are trying to use the spring boot starter which automatically tries to configure a database using spring autoconfiguration. Can you clarify with which database do you want to use Activiti? If you want to use Sybase you will need to contribute back to the project with Sybase support. Alternatively, you can not use the starter and depend on the engine directly, this will push you to provide the engine configurations for your spring environment. You can also check the -starter project and adapt as needed.
HTH