Entity Class from Database....Error Invalid resource _pm - mysql

I have created a database and table in MySQL through phpMyAdmin. I am trying to connect this to my project using Entity class from database. However I get the following error when I run my project:
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : java:module/companyDB__pm
I have searched for hours and it seems lots of people have a similar problem however I have not been able to solve it following the steps provided. For example I tried to follow the steps here: http://www.nagazuka.nl/2014/03/invalid-resource-with-netbeans-8_27.html
but has not helped. I have tried making changes in my glassfish-resources.xml and persistence.xml but nothing is working.
Any help is appreciated please!

This error Invalid resource : java:module/companyDB__pm mean that your JNDI is not exist in your server, so to solve your problem you have to create a JNDI in your GlassFish server manually with the same name companyDB
For example :
After login to your server you will see this :
Create JDBC Connection Pool
Fill information and press next i'm using PostgresSQL so in your case choose MySQL :
Fill the connection information and press finish :
To check if your connecton is succes of not press ping and check :
Now create JDBC Ressources :
Create a new JNDI specify the same name in your application and choose the pool that you already create it before and press finish :
Now you can deploy your application, hope this can help you.

In addition to the screenshots provided by #YCF_L, I went to the persistence.xml file, and changed the data source name to the same name as the JNDI name given in the JDBC Resource (jdbc/companyDB).
Also when making the Connection Pool, I selected MySQL for the database driver vendor since I am using the PHPMyAdmin MySQL. For the additional properties when making the connection pool, the following needs to be filled: URL (jdbc:mysql://:3306/databaseName), url, Server Name, Database Name, User, Password.
I was not able to make a connection to a database with no password so I needed to set one.

Related

Rundeck 3.3.6 Community - Move from H2 Db to MySql 8.0

My Ansible/Rundeck host is an Ubuntu 20.04 LTS system. I installed Ansible to tinker and then installed Rundeck. Once I was able to get the two talking and working properly (in my mind), I thought it would be best to move Rundeck to a production level DB engine instead of H2. I installed MySQL on the same host and setup the DB and the DB user as directed in the Rundeck docs. I then modified the RD properties file as the same document instructs but I keep getting a failure to connect to the database.
First it was this error:
WARN internal.JdbcEnvironmentInitiator - HHH000341: Could not obtain connection metadata : Could not connect to address=(host=10.10.140.23)(port=3306)(type=master) : Socket fail to connect to host:10.10.140.23, port:3306. Connection refused (Connection refused)
So then I researched the issue and it suggested to validate the user account in MySQL, grants, access, etc. - It all works from a command line testing in MySQL.
I read in one of my searches that some people had luck with removing the useSSL=false or setting it to true. That led to my next error of:
WARN internal.JdbcEnvironmentInitiator - HHH000341: Could not obtain connection metadata : Could not connect to address=(host=localhost)(port=3306)(type=master) : RSA public key is not available client side (option serverRsaPublicKeyFile)
During my research on this error, I read that I needed to add a property to allow the retrieval of the RSA keys, and I did but it didn't change a thing.
I then downloaded the Oracle MySQL jdbc driver and placed it in the var/lib/rundeck/lib folder and changed the driver class name in the properties file and then I received my next error of
WARN internal.JdbcEnvironmentInitiator - HHH000341: Could not obtain connection metadata : Could not connect to address=(host=127.0.0.1)(port=3306)(type=master) : (conn=355) Access denied for user 'sa'#'localhost' (using password: YES)
Current charset is UTF-8. If password has been set using other charset, consider using option 'passwordCharacterEncoding'
when I attempted to run Rundeck.
At this point I am back on H2 and I am too much of a Linux novice to understand what the issue may be. Can anyone kindly point me in a direction that helps as the Rundeck docks for using a MySQL DB seem to either be old or missing some content as a lot of the searches I have made on trying to resolve the issue directs me to perform things slight differently or all new commands that the Rundeck docs don't even mention.
I've fixed same issue stopping the Rundeck instance, later adding the following config on the rundeck-config.properties file (at /etc/rundeck path, check this):
# works with allowPublicKeyRetrieval=true
dataSource.url = jdbc:mysql://mysql_server_ip/rundeck?autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
dataSource.username=rundeckuser
dataSource.password=your_password
dataSource.driverClassName=com.mysql.cj.jdbc.Driver
# to store projects on backend
rundeck.projectsStorageType=db
Next, flushing the connections on the database side with mysqladmin flush-hosts -u root -p.
Now, starting your Rundeck service, you can check that is using MySQL 8 as a data source for your projects.
EDIT: On the MySQL side, make sure that you've created the user properly, I followed these steps:
CREATE DATABASE rundeck;
CREATE USER 'rundeckuser'#'%' IDENTIFIED BY 'P4ssw0rd';
GRANT ALL PRIVILEGES ON rundeck.* TO 'rundeckuser'#'%';
exit;
Also check how MySQL 8 is storing the user's passwords.

Connection CLOUD-SQL to Google-Data-Studio, what is wrong?

I'm trying to establish a connection between Cloud SQL and Data Studio. I've already tried to make a connection through the MySQL connector with a MySQL db and it failed because I think the Router did not allow the connection.
Then I transferred the db on the cloud but I have the same error!!! Which is:
ID errore: f73c5f49
I already opened Cloud-SQL to all the Data Studio IP addresses, I've created users with "%" and given them all the privileges, I created instance, db and user in CLOUD-SQL (MySQL, 2nd generation).
What else can I try? Could it still be a Router problem?I have to do that for work but it keeps saying that connector parameters are wrong.
PLEASE HELP <3 THANKS A LOT
A common error is to write the instance name instead of the "instance connection name".
You can find the "Instance Connection Name" in the instance page, in the overview section, and normally the format is something like:
[PROJECT_ID]:[region]:[NAME_SQL_INSTANCE]
I also had a similar connection problem with MySql 8.0 but changing to 5.7 fixed it.

Libreoffice base - "The driver class 'com.mysql.jdbc.Driver' could not be loaded" occurs even after adding class path

I am trying to connect Libreoffice base to an already existing database. To do so, I have done the following:
1)
2) I chose the "Connect using JDBC" option, and provided the database name and server. On testing class, it shows that the driver class has been loaded successfully.
3) I provided the user name and password and tested the connection, which gave me the following,
I am getting this error even though I provided the path to the .jar's. I have tried to restart libreoffice and also checked mysql.jar, for the jdbc driver (which was present) using the archive manager.
I tried referring to this at first,but the error still remained. How do I get rid of this error and establish the connection to the database ?

Connecting to a MySQL db with the anylogic objects

I'm trying to connect to a local MySQL database, with the anylogic object "database".
I'm using the type: "Other Database", and the connection URL: "Server=localhost;Database=anylogicdata;"
but I constantly get a RuntimeException saying: "not suitable driver found"
The help file says that you have to install the driver, but i don't know which or if it is my connection URL that is the problem.
Does anyone have some pointers to help me along the way?
You need a JDBC driver to be able to connect to a MySQL server from Java (that AnyLogic is based on) and you can find one here. After you have installed the driver you should find it in the list of available JDBC drivers in AnyLogic. The name should be com.mysql.jdbc.Driver if you chose the suggested one.
First you have to download and add the mysql-connector-java-*.jar file to the anylogic-project.
Then you have to type com.mysql.jdbc.Driver into the JDBC driver dropdown box. finally the connection string should look something like
jdbc:mysql:[host/db]?:[port]
another thing I found that might be helpfull to others, is that you can get the java connection from the anylogic db object: database.getConnection() this is very usefull if you want to create your own query. eg create a bulk insert instead of the single insert that Anylogic provides.

Unable to initialize provider. Missing or incorrect schema

I have upgraded my server machine to use MySQL Connector 6.3.4 and in our website we also added Membership role provider.
When I run the website I am getting this error.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unable to initialize provider. Missing or incorrect schema.
My sql server is version 5.0.90 community-net.
Is there any setting which have to be changes on server side while upgrading connector
This is tag in my web.config file.
Since when I run the website on local machine it will run successfully, but on server I am not able to run it and getting above error.
There is no mistake in connection string
What are server side setting which we to do while upgrading the connector....
thanks
I myself running into the same problem. I m using Mysql connector 6.3.0.0
So far I came across following suggestions when seaching on net:
1) Add "MySql.Data.dll" & "MySql.Web.dll" into your application "bin" folder.
2) Add reference to above to dlls in your application .
3) Add autogenerateschema="true" in your web.config file for required sections.
4) Check your Mysql connector version - make sure that the one that is in your bin folder is mentioned in your web.config file.
5) Check your connection string - make sure it is correct and connected successfully.
6) Check mysql membership related table structure.
7) Check schema version in "my_aspnet_schemaversion" table (e.g since you have upgraded to newer version I insist you should check this).
8) If the problem is on remote machine (e.g Production Server) you may wan to check this : http://www.reggieburnett.com/referencing-connectornet-on-a-remote-machine
I m sure you may gone through this list but I would like you to check schema version in "my_aspnet_schemaversion" table (e.g compare "version" field value of your local and remote table) since your upgrading to newer version.
BTW: I have checked this list for my problem but it did not help. I hope it may be of some help to you.
Edit:
Hi,
We are able to fix this error by following:
1) Deleted the tables for memberships in the db and had the mysql membership provider regenerate them
2) than set the Aministration.config file to trust the Mysql Membership Provider (e.g related to IIS admin)
Regards,
Gaurav
I had this same problem after checking all the things in Gaurav's post. It ended up being that the user account I was using in my connection string did not have necessary permissions to alter the db schema (I had autogenerateschema set to true). Once I changed my connection string to a user with more privileges (I used the 'root' user) then it updated the schema, and I changed the connection string back to the original user.
Always make sure that the Datasource is set to the real ip address and not localhost and check the passwords and usernames too. I am working with these clients and their ip address keeps changing and every time they do that, I get the same error
I know this is an old thread but maybe this will help someone. I was having this issue and realized that I was editing the wrong machine.config
At first I was editing on under C:\Windows\Microsoft.NET\Framework64....
Once I found the one for my .NET version under C:\Windows\Microsoft.NET\Framework.... and edited the correct spots, it worked fine following the instructions on MySQL's site.