Oracle ADF Glassfish MySQL - Data Source Error - mysql

I have set up ADF essentials library on my glassfish server as specified here . I am able to successfully deploy applications to the glassfish server from jDeveloper and the application runs fine until there is a database operation involved and it is when it throws up the following error
No object bound to name java:comp/env/jdbc/myDataSource
The application works fine on IntegratedWeblogicServer, so am guessing I have not set up the mysql datasource in my glassfish properly. I have setup connection as shown here and the connection name is "myDataSource" (which is same as provided in the jDeveloper's DB connection name).
Help!!!

You need to set the name of the datasource in your Application Module configuration tab to match the name of the datasource you defined in your GlassFish instance.

Related

java.sql.SQLException: No database selected with MySQL datasource in JBoss

I have a JBoss EAP 7.3 server and I have created a MySQL datasource
When my app tries to execute a query (just a simple select statement), it throws java.sql.SQLException: No database selected
According to the datasource setting I have already specified the database name in the URL.It should have selected the database for me.
Did I missed anything or any config I can look into?
I had the same issue using Wildfly application server with MySQL. The solution is to add a Connection property like this: databaseName=test

Unable to connect to Aurora MySql using .net core application deployed on Aws Ecs

I have an application in .net core 3.1 and I am using MySql with that. To connect to MySql I am using Pomelo.EntityFrameworkCore.MySql nuget.
My .net core application is deployed as a docker container on AWS ECS and I am using Aurora MySql RDS to store data. I have granted "Publicly accessible" access to the Aurora MySql and I can connect to the db using MySql workbench and also with my .net core application using localhost. But when I deploy the application and try to perform any db action then it starts giving throwing exception:
An exception has been raised that is likely due to a transient
failure. Consider enabling transient error resiliency by adding
'EnableRetryOnFailure()' to the 'UseMySql' call.
Then I have added retry pattern like this:
services.AddDbContextPool<DataContext>(options =>
options.UseMySql(Configuration.GetConnectionString("DefaultConnection"), builder =>
{
builder.EnableRetryOnFailure(5, TimeSpan.FromSeconds(5), null);
}
);
and my connection string is something like this:
"DefaultConnection": "Server=db-cluster-1-instance-1.cqb2fsjwx78p.us-east-2.rds.amazonaws.com;Database=dbName;User ID=admin;Password=password;port=3306"
After adding retry pattern. I am getting this error:
"Maximum number of retries (5) exceeded while executing database
operations with 'MySqlRetryingExecutionStrategy'. See inner exception
for the most recent failure."
So I suspect, it's something else. What am I doing wrong here? Or it might be something wrong at aws side
So the issue was related to docker image I was pulling.
I was using mcr.microsoft.com/dotnet/core/sdk:3.1. Changing it to mcr.microsoft.com/dotnet/core/sdk:3.1-bionic worked.
https://github.com/dotnet/SqlClient/issues/222
Add SslMode=None to your connection string and see if the connection works (see MySqlConnector's Connection String Options). The transient exception just means, that Pomelo (i.e. MySqlConnector) was unable to connect to the database server.
So this is related to connection problems (either fixable by altering the connection string or by changing your Aurora/firewall configuration).

How to connect Visual Studio to Aurora MySQL DB?

In Visual Studio 2019 menu: Tools -> Connect To Database I see "MySQL Database" data provider, but an attempt to connect to my aurora database finishes with weird error:
"Microsoft Visual Studio / Unable to connect to any of the specified MySQL hosts. Sequence contains more than one matching element"
I have Aurora DB based on MySQL 5.6.10. I can connect to it using the latest MySQL Workbench 8.0.18. I have the latest "MySQL for Visual Studio 1.2.9" and Connector/NET 8.0.18. I work with .NET Framework 4.7.2. I can also connect to other (normal) MySQL instances from the Visual Studio, but not to Aurora DB.
My final target is to create ADO.NET Entity Data Model from the amazon db, but this fails on the same error message.
Is there any guide how to connect MySQL Aurora DB with .NET Framework (not .NET Core)? A guide to extremely simple application which can download single value from any table would mean a significant step forward for me.
OK. I found it's a Bug #97448 introduced in MySql.Data 8.0.18. Workaround is to define server name by IP address instead of xxx.rds.amazonaws.com address.
It's a know bug.
FYI the previous version of mysql.data (v6.10.9) is also affected.
As a workaround you could resolve the DNS value to an IP address manually.
In the code example below I check if the server value is an IP then I resolve the DNS name when the value is not an IP address.
if (IPAddress.TryParse(server, out var ipAddress))
{
// The server value is an IP address, it can be used directly
}
else
{
server = Dns.GetHostEntry(server).AddressList.FirstOrDefault()?.MapToIPv4().ToString();
}
return new MySqlConnectionStringBuilder
{
Server = server
// ...
};

Getting Started with EF Core on ASP.NET Core with an Existing Database

I am trying to connect my web api to an existing database using this command by going in tools-> nuget package manager -> nuget package manager console
Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
But it says
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: Named
Pipes Provider, error: 40 - Could not open a connection to SQL Server)
It's supposed to get all tables from this database and show them in models, I've done this before and forgotten the procedure, I'm just trying to connect it to database first so I an copy the rest of the code and get the API working

use of universal providers and mysql

I created an asp.net mvc 4 application, and added universal providers, because I need to create a custom membership provider that read users data from a my sql database.
When I work on the developer workstation it's all ok, but when I deploy on the server, where there is not Sql Server installed i receive an error. trying to open DefaultConnection.
In the InitializeSimpleMembershipAttribute that is created from the wizard, I have this:
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: false);
this call initialize the db connection, do nothing, and is not used by the custom membership provider, but must be done at startup.
the connection string is:
add name="DefaultConnection" connectionString="Data Source=...;Initial Catalog=...;User id=...;Password=..." providerName="System.Data.SqlClient" />
the problem is that I don't know how to configure to use a mysql db and pass this control in the startup of the application.
If I have to install it in a server with Sql server installed, I configure it properly, and after the initial call the mysql membership provider works without problem, but i have problems when i cannot use this workaround, and exception is raised at the call to InitializeDatabaseConnection.
How can I fix this problem?