Monitoring c3p0 connections using Jconsole - c3p0

Hi I am trying to monitor the connections opened by c3p0 using JConsole.
I am following tutorial mentioned in
http://amemon.wordpress.com/2007/07/15/monitoring-c3p0-using-jmxjconsole/
But when I open the jconsole under Mbeans tab I am not able to find package for C3P0.
Any ideas??

Related

Connect to Google Cloud MySql From Cloud Run (knative)

For a sample project I am working on (https://gitlab.com/connorbutch/reading-comprehension-ws), I am having issues connecting to a google cloud mysql database from google cloud run. However, when I run locally with the same args (in both docker and kubernetes) the application looks to succeed.
The steps I followed in setting up my google cloud run application are listed here (https://cloud.google.com/sql/docs/mysql/connect-run). I included the mysql db in the cloud database info. Things I have tried
connecting using ip address in jdbc connection string (which works locally, but this statement on the page suggests it might not on google cloud run, "Cloud Run (fully managed) does not support connecting to the Cloud SQL instance using TCP. Your code should not try to access the instance using an IP address such as 127.0.0.1 or 172.17.0.1.")
connecting using unix socket as suggested, server does not even start
When I start the application with the ip address in the jdbc url, on google cloud, it looks like the app starts successfully:
2020-02-12T02:51:01.733606Z 2020-02-12 02:51:01.733 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-02-12T02:51:01.740162Z 2020-02-12 02:51:01.739 INFO 1 --- [ main] com.connor.Application : Started Application in 15.717 seconds (JVM running for 17.715)
However, when I make the first request, I see the following:
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
Caused by: java.net.SocketTimeoutException: connect timed out
Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
Is there any suggestions you may have? I am wondering if it may be related to having to configure our DataSource as listed here: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java
Following the documentation steps:
Build and deploy container
Connect from Cloud Run
On the last step: “Connecting to CloudSQL” of the 2nd link instead of using the code snippet, I used the following command from the GitHub instructions:
gcloud run services update helloworld --add-cloudsql-instances [INSTANCE_CONNECTION_NAME] --set-env-vars CLOUD_SQL_CONNECTION_NAME=[INSTANCE_CONNECTION_NAME],DB_USER=[MY_DB_USER],DB_PASS=[MY_DB_PASS],DB_NAME=[MY_DB]
where "helloworld" is the name of my service.
Please be meticulous with the spacing on this command, as it can easily throw errors.
Having said that after performing a curl command I did not receive any errors, so my application runs successfully.
Additionally, during my investigation on the error you received, I came across this link, which contains a list of possible causes for this error.
Finally, since the error indicates a timeout, you could also try modifying the request timeout of Cloud Run by following this.
Some further links that could come in handy for you are:
Diagnosing issues with Cloud SQL instances
Troubleshooting Cloud Run (fully managed)
I hope this information helps.
Sadly the https://cloud.google.com/sql/docs/mysql/connect-run document is currently not documenting the Knative instructions. Any time you see "Cloud Run (fully managed)" that's not to Kubernetes implementation.
If you are using Cloud Run on a Kubernetes/GKE cluster, this is probably more applicable. https://cloud.google.com/sql/docs/mysql/connect-kubernetes-engine That said this approach uses "Cloud SQL Proxy" sidecar container, which is not yet a notion supported by Knative today.
However, using those instructions, you can connect to Cloud SQL instance over a private IP, as GKE clusters can be in a VPC (though "Cloud Run fully-managed" applications currently cannot).

websockets disconnects on wildfly openshift

I have web application deploy on WildFly Application Server 8.2.0.Final on Openshift.
My application serves websockets endpoint.
I connect to the websocket endpoint with my java (tyrus implementation) client application and after short period (few hours) connection is closed by server side. I receive close reason "Closed abnormally" and close reason code: "1006".
Client does automatic reconnection and then exactly every hour connection is again broken with mentioned close reason.
Is this builtin mechanism working on openshift serverside? Some sort of cleaning mechanism?
I would like to have permanent websocket connection to server.
Would buying openshift broze/silver support solve this problem?
The problem is in your browser, not in the server:
Close Code 1006 is a special code that means the connection was closed abnormally (locally) by the browser implementation.
If your browser client reports close code 1006, then you should be looking at the websocket.onerror(evt) event for details.
See this SO answer for more details:
https://stackoverflow.com/a/19305172/212224

Use c3p0 with JBOSS AS 7.1.1

I read in c3p0´s manual link that it is possible to use c3p0 library inside JBOSS as an MBean.
Once configured correctly, I would like to reference the new C3P0PooledDataSource in my Java WAR through its JNDI name. As I am using Spring
it would be something similar to:
[src/webapp/WEB-INF/applicationContext.xml]
<jee:jndi-lookup id="dataSource" jndi-name="java:PooledDS" />
However, I don´t know how to configure this library properly. I tried to place c3p0-0.9.2.1.jar and c3p0-service.xml in the folders commented in the manual
but I had no luck.
I am currently developing a project which uses a MySql database, so I have instaled the mysql connector inside the JBOSS AS 7.1.1 server.
I have to say that if I integrate c3p0 and MySql connector in my project I can deploy it correctly. So...:
Is it possible to use c3p0 connection pool inside JBOSS AS 7.1.1 as described in its manual? How should I configure it?
I started to "play" with c3p0 because of its large number of configuration properties, but I don´t know if c3p0 is better than embedded JBOSS pooling capabilities.
Does c3p0 library deserve to be used instead of JBOSS embedded connection pool (i.e. configuring a datasource with the admin console/web) ?
I appreciate any comments to these matters.
Thanks in advance.

Sqoop authenticates but fails to start a map reduce job

I am trying to transfer data using sqoop from HDFS to the MSSQL server. But for some reasons, sqoop hangs at
tool.BaseSqoopTool: Enabled debug logging.
sqoop.ConnFactory: Added factory com.microsoft.sqoop.SqlServer.MSSQLServerManagerFactory specified by /usr/lib/sqoop/conf/managers.d/mssqoop-sqlserver
DEBUG sqoop.ConnFactory: Loaded manager factory: com.microsoft.sqoop.SqlServer.MSSQLServerManagerFactory
DEBUG sqoop.ConnFactory: Loaded manager factory: com.cloudera.sqoop.manager.DefaultManagerFactory
DEBUG sqoop.ConnFactory: Trying ManagerFactory: com.microsoft.sqoop.SqlServer.MSSQLServerManagerFactory
INFO SqlServer.MSSQLServerManagerFactory: Using Microsoft's SQL Server - Hadoop Connector
INFO manager.SqlManager: Using default fetchSize of 1000
DEBUG sqoop.ConnFactory: Instantiated ConnManager com.microsoft.sqoop.SqlServer.MSSQLServerManager#45db05b2
INFO tool.CodeGenTool: Beginning code generation
DEBUG manager.SqlManager: No connection paramenters specified. Using regular API for making connection.
I check the firewall and it is allowing connections without any restrictions. Sqoop gets authenticated but doesnt initiate a map reduce job after it gets authenticated. Any one has faced similar problems before?
Try using --verbose to print more information.
Is your SQL Server running on a Virtual Machine? I had a similar problem with Oracle. I was running Oracle on a VM with a static IP and a Bridged network adapter. Servers within the same network as the Oracle server could connect fine, but servers outside the network showed these same symptoms. The solution was to change from a Bridged Interface to a NAT'd interface. Then you need to set up a port forwarding rule on the host machine to your database server, and make your Sqoop connection to the host machine IP rather than the VM's IP. It took me several days to get this figured out. Hope it helps.
We has MsSQL server running on our machines. The problem was that the particular version of JVM (Java(TM) SE Runtime Environment (build 1.6.0_29-b11)) had bug and caused the client to hang in the getconnection method.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7103725
We upgraded to a newer version and things worked fine.

Do I need to use C3P0 pooling library in my (grails) web application?

I am not familiar at all with connection pooling library. I've just discovered it through this blog article) and I am not sure that I should use one in my web application based on grails/hibernate/mysql.
So my question is simple : in which situations would you suggest to integrate a connection pooling library into a grails application? Always, Never or only over some connections threshold?
P.S. : If you have ever used successfully C3P0 in your web application, I will greatly appreciate to hear your feedback (in terms of visible positive effects).
Regardless of which pooling implementation, you should use a connection pool always in your web application. Open a connection with the database is a very expensive task and being able to reuse a already existing and idle connection greatly improves your site performance.
A connection can be managed by the application server (Tomcat, JBoss, Glassfish...) or by your application. The latter is easier to setup but it's hard to customize per deployment. Configuring a connection pool on the application and setting your site to consume it makes easy to the fine tune the connection pool parameters, like: minimum connections to keep open, max idle time and so on.
My experience with this is pretty limited, but I ended up using C3P0 for the simple reason that Hibernate does not seem to handle MySQL restarts. I got a "Broken pipe" every morning because our hosting service restarted MySQL every night.
I googled it and the only advice I could find was to use... the connection pool of the app server or C3P0. For me, the latter works just fine.
I always use a connection pool for two reasons:
Because opening connections is an expensive operation
It's dead-simple to set one up to work transparently, so there's no real advantage to not using one.
If you're already using hibernate, just modify your hibernate.cfg.xml's connection.provider_class to use org.hibernate.connection.C3P0ConnectionProvider and throw the c3p0 jar file into your servlet's WEB-INF/lib folder. Done.
If you're using JNDI and a GlobalNamingResources declaration, modify the type property to point to com.mchange.v2.c3p0.ComboPooledDataSource and throw the c3p0 jar into Tomcat's /lib folder. Done.
C3P0 is a very decent pool but I would still recommend to use the connection pool of your app server or servlet engine and to configure Grails to use it via a regular DataSource. Use a stand-alone connection pool when you can't do that (in which case C3P0 is a good choice).