C3P0 dont work (org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider)

Hi!
I recieved this warning when I execute my app:

sep 22, 2018 5:59:36 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator c3p0ProviderPresent 
WARN: HHH000022: c3p0 properties were encountered, but the org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider provider class was not found on the classpath; these properties are going to be ignored.

The problem is: I’m using Hibernate-core-5.2.6.jar (with all his libraries), C3p0-0.9.5.2.jar and hibernate-c3p0-5.2.6.Final.

It should work. But It doesnt. What I’m doing wrong?

Do you get this error when using Hibernate Tools or when bootstrapping Hibernate ORM? You should add the entire StackTrace that you get as well.

Hi vlad! Thanks for your answer :slight_smile:
I recieve this error when my app connect for first time to database with hibernate. Really a dont know what is this " Hibernate Tools or when bootstrapping Hibernate ORM", I’m a little noob hahah

This is all that I recieved from console when my app connect with hibernate.

sep 23, 2018 6:29:43 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
sep 23, 2018 6:29:43 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.0.Final}
sep 23, 2018 6:29:43 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
sep 23, 2018 6:29:43 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
sep 23, 2018 6:29:43 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
sep 23, 2018 6:29:43 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
sep 23, 2018 6:29:43 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
sep 23, 2018 6:29:44 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator c3p0ProviderPresent
WARN: HHH000022: c3p0 properties were encountered, but the org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider provider class was not found on the classpath; these properties are going to be ignored.
sep 23, 2018 6:29:44 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
sep 23, 2018 6:29:44 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
sep 23, 2018 6:29:44 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: false
sep 23, 2018 6:29:44 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://52.14.43.34:3306/J4G]
sep 23, 2018 6:29:44 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=jsp, password=****}
sep 23, 2018 6:29:45 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
sep 23, 2018 6:29:45 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
sep 23, 2018 6:29:45 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory

The error message is quite explicit. Are you using Maven or Gradle? If you are not, you need to start using a proper build tool.

I’m sure that I’m not using Maven, I created Dynamic web project to use it in tomcat. I didnt create a Maven or Gradle project.

So, If I dont change all my project to Maven o Gradle I cant use c3p0,no?

Yes, you can use c3p0 without a build tool. But, in a real project you’ll always use Maven or Gradle, and posting the pom.xml is how we could help you.

If you’re setting your project in the IDE alone, only you will ever know what you are doing there.

Okey!

I will try to change my project to Gradel or Maven.

Thanks :slight_smile:

That’s the spirit! Once you learn to use a buid tool, you’ll never look back.

1 Like

Thanks Vlad!

I have a doubt, I transformed my project to Maven and I added all the dependencies. But the “Query” appears deprecated, and I have the same jars (dependencies). Am I doing something wrong?

If you inspect the JavaDoc of the org.hibernate.Query, you will find the replacement.

How can I see there how it works? I learned with examples, but there is only the query class. I never learn from a Javadoc, and I dont know use it :sweat_smile:

How can I see there how it works?

You write a unit test like this one provided in our test case templates.

I learned with examples, but there is only the query class.

You also need to read the User Guide.

I never learn from a Javadoc, and I don’t know use it.

If you open that link, you’ll know what to do.

Thanks @vlad !
I do this, but I recieve this erros:

GRAVE: El Servlet.service() para el servlet [Servlets.Login] en el contexto con ruta [/Just] lanzó la excepción [La ejecución del Servlet lanzó una excepción] con causa raíz
java.lang.NoSuchMethodError: org.hibernate.Session.createQuery(Ljava/lang/String;Ljava/lang/Class;)Lorg/hibernate/query/Query;
	at usersLogin.EncryptData.comprobarLoginMain(EncryptData.java:197)
	at Servlets.Login.Checklogin(Login.java:95)
	at Servlets.Login.doPost(Login.java:40)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:407)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)

It means you have an older version of Hibernate on your classpath.

After you migrate your project to Maven, you need to run the following command:

mvn dependency:tree

and see what versions of Hibernate you have set up in your project. This will prove that you are not seeing multiple versions of Hibernate which can lead to that problem.

Where should I round this command? On eclipse? On tomcat server?

In the command line, in the project root folder. You need to read the documentation of Maven as well. There’s no other way to learn all these tools and frameworks.

Okay, i will do this. I thought that this will be more easy haha Thanks @vlad

Maven

This what I found, and I only have 1 version of hibernate working.

Is this what you say?

That’s not what I told you. I’ll close this topic since there’s nothing to add on my side and you already have the solution to fix the problem.

Okey, thanks vlad. And sorry for ask a lot.