Yoo coderrs, have problem connect and write table to my online free database. Problem is hereUnable to create requested service
and Unable to make JDBC Connection
"C:Usersmyhome.jdksopenjdk-17.0.1binjava.exe" "-javaagent:C:Program FilesJetBrainsIntelliJ IDEA Educational Edition 2021.2.3libidea_rt.jar=56594:C:Program FilesJetBrainsIntelliJ IDEA Educational Edition 2021.2.3bin" -Dfile.encoding=UTF-8 -classpath "C:UsersPatrik SeverínIdeaProjectsuntitledjpatargetclasses;C:UsersPatrik Severín.m2repositoryorghibernatehibernate-core5.6.3.Finalhibernate-core-5.6.3.Final.jar;C:UsersPatrik Severín.m2repositoryorgjbossloggingjboss-logging3.4.2.Finaljboss-logging-3.4.2.Final.jar;C:UsersPatrik Severín.m2repositorynetbytebuddybyte-buddy1.11.20byte-buddy-1.11.20.jar;C:UsersPatrik Severín.m2repositoryantlrantlr2.7.7antlr-2.7.7.jar;C:UsersPatrik Severín.m2repositoryorgjbossspecjavaxtransactionjboss-transaction-api_1.2_spec1.1.1.Finaljboss-transaction-api_1.2_spec-1.1.1.Final.jar;C:UsersPatrik Severín.m2repositoryorgjbossjandex2.2.3.Finaljandex-2.2.3.Final.jar;C:UsersPatrik Severín.m2repositorycomfasterxmlclassmate1.5.1classmate-1.5.1.jar;C:UsersPatrik Severín.m2repositoryjavaxactivationjavax.activation-api1.2.0javax.activation-api-1.2.0.jar;C:UsersPatrik Severín.m2repositoryorghibernatecommonhibernate-commons-annotations5.1.2.Finalhibernate-commons-annotations-5.1.2.Final.jar;C:UsersPatrik Severín.m2repositoryjavaxxmlbindjaxb-api2.3.1jaxb-api-2.3.1.jar;C:UsersPatrik Severín.m2repositoryorgglassfishjaxbjaxb-runtime2.3.1jaxb-runtime-2.3.1.jar;C:UsersPatrik Severín.m2repositoryorgglassfishjaxbtxw22.3.1txw2-2.3.1.jar;C:UsersPatrik Severín.m2repositorycomsunistackistack-commons-runtime3.0.7istack-commons-runtime-3.0.7.jar;C:UsersPatrik Severín.m2repositoryorgjvnetstaxexstax-ex1.8stax-ex-1.8.jar;C:UsersPatrik Severín.m2repositorycomsunxmlfastinfosetFastInfoset1.2.15FastInfoset-1.2.15.jar;C:UsersPatrik Severín.m2repositorymysqlmysql-connector-java8.0.28mysql-connector-java-8.0.28.jar;C:UsersPatrik Severín.m2repositorycomgoogleprotobufprotobuf-java3.11.4protobuf-java-3.11.4.jar;C:UsersPatrik Severín.m2repositoryjavaxpersistencejavax.persistence-api2.2javax.persistence-api-2.2.jar" sk.hibernate.App jan 28, 2022 10:05:46 AM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation INFO: HHH000204: Processing PersistenceUnitInfo [name: sk.hibernate] jan 28, 2022 10:05:46 AM org.hibernate.Version logVersion INFO: HHH000412: Hibernate ORM core version 5.6.3.Final jan 28, 2022 10:05:46 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {5.1.2.Final} jan 28, 2022 10:05:46 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!) jan 28, 2022 10:05:46 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001005: using driver [com.mysql.cj.jdbc.Driver] at URL [mysql://****************:******************@bkt9ucjj52rre9ut1cix-mysql.services.clever-cloud.com:3306/bkt9ucjj52rre9ut1cix] jan 28, 2022 10:05:46 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001001: Connection properties: {password=****, user=ujfnz0sxud23qruy} jan 28, 2022 10:05:46 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001003: Autocommit mode: false jan 28, 2022 10:05:46 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init> INFO: HHH000115: Hibernate connection pool size: 20 (min=1) Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:175) at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:173) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at sk.hibernate.App.main(App.java:15) Caused by: org.hibernate.HibernateException: Unable to make JDBC Connection [mysql://ujfnz0sxud23qruy:lqoN4PMPxWAAUjNEKuv8@bkt9ucjj52rre9ut1cix-mysql.services.clever-cloud.com:3306/bkt9ucjj52rre9ut1cix] at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:60) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.addConnections(DriverManagerConnectionProviderImpl.java:409) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.<init>(DriverManagerConnectionProviderImpl.java:275) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.<init>(DriverManagerConnectionProviderImpl.java:249) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections$Builder.build(DriverManagerConnectionProviderImpl.java:453) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:98) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:73) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:107) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:246) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:146) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ... 14 more
1class package sk.hibernate;
import sk.hibernate.model.Message; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; public class App { public static void main( String[] args ){ EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("sk.hibernate"); EntityManager entityManager = entityManagerFactory.createEntityManager(); entityManager.getTransaction().begin(); entityManager.persist(new Message("Prva sprava")); entityManager.persist(new Message("Druha sprava")); entityManager.getTransaction().commit(); entityManager.close(); } }
2.class
package sk.hibernate.model; import javax.persistence.*; import java.util.Date; @Entity public class Message { @Id @GeneratedValue(strategy = GenerationType.IDENTITY ) // @Column(name = "ID") private Long id; // @Column(name = "MESSAGE") private String message; private Date CREATE_DATE; public Message() { } public Message(String message) { this.message = message; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public Date getCREATE_DATE() { return CREATE_DATE; } public void setCREATE_DATE(Date CREATE_DATE) { this.CREATE_DATE = CREATE_DATE; } }
persistence.xml
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.2" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"> <persistence-unit name="sk.hibernate" transaction-type="RESOURCE_LOCAL"> <class>sk.hibernate.model.Message</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/> <property name="javax.persistence.jdbc.url" value="mysql://*****************:************************@bkt9ucjj52rre9ut1cix-mysql.services.clever-cloud.com:3306/bkt9ucjj52rre9ut1cix"/> <property name="javax.persistence.jdbc.user" value="******"/> <property name="javax.persistence.jdbc.password" value="****"/> <property name = "hibernate.show_sql" value = "true" /> <property name = "hibernate.format_sql" value = "true" /> <!--<property name = "hibernate.hbm2ddl.auto" value = "update" />--> </properties> </persistence-unit> </persistence>
POM
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>sk.hibernate</groupId> <artifactId>jpa</artifactId> <version>1.0-SNAPSHOT</version> <name>jpa</name> <!-- FIXME change it to the project's website --> <url>http://www.example.com</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties> <dependencies> <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>5.6.3.Final</version> </dependency> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.28</version> </dependency> <!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api --> <dependency> <groupId>javax.persistence</groupId> <artifactId>javax.persistence-api</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> <build> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> <plugin> <artifactId>maven-site-plugin</artifactId> <version>3.7.1</version> </plugin> <plugin> <artifactId>maven-project-info-reports-plugin</artifactId> <version>3.0.0</version> </plugin> </plugins> </pluginManagement> </build> </project
*MYSQL_ADDON_DB="bkt9ucjj52rre9ut1cix" MYSQL_ADDON_HOST="bkt9ucjj52rre9ut1cix-mysql.services.clever-cloud.com" MYSQL_ADDON_PASSWORD="***" MYSQL_ADDON_PORT="3306" MYSQL_ADDON_URI="mysql://******************:***********************@bkt9ucjj52rre9ut1cix-mysql.services.clever-cloud.com:3306/bkt9ucjj52rre9ut1cix" MYSQL_ADDON_USER="****" MYSQL_ADDON_VERSION="8.0"*
Advertisement
Answer
I just accessed your database with the following URL:
jdbc:mysql://******************:******************@bkt9ucjj52rre9ut1cix-mysql.services.clever-cloud.com:3306/bkt9ucjj52rre9ut1cix
(I masked the credentials). So you missed the prefix “jdbc:”
You should quickly change your username and password now. You don’t want all of The Internet to have access, do you? I think someone might have renamed one of your tables…
Oh, and say hi to Patrik Severín for me, will you? 😉