Setting up a JDBC data source and connection pool - mysql

I have followed every step in the tutorial: https://netbeans.org/kb/docs/web/mysql-webapp.html but the data source and connection pool are not displayed on the Server Resources node.
after completing all the other steps and deploying the project, i get the following error...
exception
javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc/IFPWAFCAD"
root cause
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc/IFPWAFCAD"

Related

EFCore MAC - Unable to find an entry point named 'AppleCryptoNative_SslCreateContext'

when running
dotnet ef database update --startup-project ../webapi/webapi.WebAPI.csproj
on my MAC 10.13.5
I get this error -
System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught) ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.EntryPointNotFoundException: Unable to find an entry point named 'AppleCryptoNative_SslCreateContext' in shared library 'System.Security.Cryptography.Native.Apple'.
at Interop.AppleCrypto.SslCreateContext(Int32 isServer)
at System.Net.SafeDeleteSslContext.CreateSslContext(SafeFreeSslCredentials credential, Boolean isServer)
at System.Net.SafeDeleteSslContext..ctor(SafeFreeSslCredentials credential, SslAuthenticationOptions sslAuthenticationOptions)
at System.Net.Security.SslStreamPal.HandshakeInternal(SafeFreeCredentials credential, SafeDeleteContext& context, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, SslAuthenticationOptions sslAuthenticationOptions)
--- End of inner exception stack trace ---
...
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)
I originally thought this was my local docker database was not available but when connecting to new database instance it still occurs, this was working yesterday.
Whilst typing this I came across this, but thought would just add the answer as someone on a MAC EF Core install may miss that also when searching -
A connection was successfully established with the server, but then an error occurred during the pre-login handshake
Cleaning my project (I personally deleted all the folders) and rebuilding, sorted it!

How to confiure the JDBC URL with service name when use C3P0 CONNECT oracle database?

I have meet one issue:
There is one database,it could be connected by sqldeveloper tools
But I want to use c3p0 to connect the database with the jdbcurl:
jdbc:oracle:thin:#2.2.6.11:2709:hl.webtest.com
get these error:
WARN - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask#55854763 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (5). Last acquisition attempt exception:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
why C3p0 throw the error? It seemed that the jdbcurl is wrong, what is correct jdbcurl with the Service Name?
jdbc:oracle:thin:#//2.2.6.11:2709/hl.webtest.com
it is use service_name, not the SID
You need the // and the /

Authentication mysql to .Net

I have Mysql DB connected to .NET MVC. When i connect remote it some times works fine and some times i have this error msg:
MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to
host 'ServerName' for user 'UserName' using method
'mysql_native_password' failed with message: Reading from the stream
has failed. ---> MySql.Data.MySqlClient.MySqlException (0x80004005):
Reading from the stream has failed. ---> System.IO.IOException: Unable
to read data from the transport connection: An established connection
was aborted by the software in your host machine. --->
System.Net.Sockets.SocketException: An established connection was
aborted by the
Please how can i make Authentication ? Any ideas to solve it?
This is a common error when some kind of deadlock occurs on the database more commonly a connection has been open a long time and gets shut down at the database end even though it is still in-use in your web application.
In my code, I used a suggestion from Microsoft, that retries the database command if it fails. The link is here: http://social.technet.microsoft.com/wiki/contents/articles/4235.retry-logic-for-transient-failures-in-windows-azure-sql-database.aspx Similar things exist for other non-Azure problems that use RetryPolicy.
What this means in a simple (Azure in my case) example is:
private static RetryPolicy<SqlAzureTransientErrorDetectionStrategy> retryPolicy = new RetryPolicy<SqlAzureTransientErrorDetectionStrategy>(new Incremental(3, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)));
// Inside your database function
retryPolicy.ExecuteAction(() =>
{
db.ExecuteStoredProc("procRecordMetric", cmd);
});
In my case, this was caused by ssl being enabled on the mysql server.
Here is a snippet from my.cnf
#ssl-ca = /etc/ssl/mysql/ca-cert.pem
#ssl-cert = /etc/ssl/mysql/server-cert.pem
#ssl-key = /etc/ssl/mysql/server-key.pem
Commenting these 3 lines fixed the issue for me.

MSTest error - MySQLConnection aborts connection after upgrading to Connector 6.6.6

My database is MySQL 5.5.34 and I'd been using the MySQL Connector.NET version 6.5.4.
After uninstalling the 6.5.4 and installing version 6.6.6, I'm having issues with the connection aborting. The relevant code, which looks essentially like the following worked fine prior to the upgrade.
MySqlConnection connection = new MySqlConnection("server=localhost;port=7654;uid=matt;pwd=password");
connection.Open(); // this results in the exception
This works fine when I do this in a simple console application but does not work in my MS Test
The Exception I get is:
MySql.Data.MySqlClient.MySqlException: "Authentication to host 'localhost' for user 'matt' using method 'mysql_native_password' failed with mesage: Reading from the stream has failed"
Drilling down into the exception, the Inner Exception is "Unable to read data from the transport connection: An established connection was aborted by the software in your host machine."
I've tried with both VS 2010 and VS 2013. Same error for both.
Ideas?

Mysql Tomcat 6 Connection refused

I have a tomcat app running on a ubuntu cloud server. Everything was working well until a few hours ago. I tried to add a second tomcat app with a similar data source resource in the context.xml. The idea was that the first app would connect to the first DB and the second to the second Database. I called the datasources the same name. It didnt work.
Now I have removed the second app and I cant connect to the database from the original app. All with the same context.xml as it was before I started today. This is driving me crazy.
I get this exception.
Caused by: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Server connection failure during transaction. Due to underlying exception: 'java.net.ConnectException: Connection refused'.
** BEGIN NESTED EXCEPTION **
java.net.ConnectException
MESSAGE: Connection refused
STACKTRACE:
java.net.ConnectException: Connection refused