I'm using grails 2.5.0 and mysql 8.0.13
dbCreate = "create-drop"
url = "jdbc:mysql://localhost/bet?serverTimezone=UTC"
driverClassName = "com.mysql.cj.jdbc.Driver"
username = "root"
password = "pepito"
For example, if I save a "Product", it's work, but if I change some code in any controller I got this error:
The type registry TypeRegistry(id=334490881,loader=groovy.lang.GroovyClassLoader) does not know about type id 1839.
Stacktrace follows:
Message: The type registry TypeRegistry(id=334490881,loader=groovy.lang.GroovyClassLoader) does not know about type id 1839
Spring Loaded: Cannot reload new version of com.bet.controller.AgentController
Reason: Interfaces changed from [org/codehaus/groovy/grails/orm/support/TransactionManagerAware, groovy/lang/GroovyObject] to [groovy/lang/GroovyObject]
Y tested in sql server and it's work
In that situation, I normally restart the application. When we change a lot in a controller, the application could not load the latest updated version of the compiled class according to that controller in some cases.
Related
I'm setting up a web API. My program.cs file looks like this:
var serverVersion = new MySqlServerVersion(new Version(8, 0, 29));
builder.Services.AddDbContext<GameDbContext>(
dbContextOptions => dbContextOptions
.UseMySql(builder.Configuration.GetConnectionString("Db"), serverVersion, mySqlOptions =>
mySqlOptions.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null))
);
And my connection string has the following template:
"ConnectionStrings": {
"Db": "Server=serverIP,port;Database=dbName;User Id=userId;Password=password;"
}
The API ill listen on localhost:7272 when building and running the project in Visual Studio itself. The API will handle the requests sent to this adress.
However, when I build and publish the project and then run the executable from the folder, it listens to localhost:5000, but no requests will be handled because of this error:
An error occurred using the connection to database '' on server ''.
I've already added the 'EnableRetryOnFailure' as suggested by others and changed the template of the connection string multiple times but still to no avail.
What can I do to fix this?
Thanks!
I've already added the 'EnableRetryOnFailure' as suggested by others and changed the template of the connection string multiple times but still to no avail. I also added the Pomelo package.
I have an application on nodejs I host them on cpanel, I did the configuration and I put it online, but I notice that the site is going well but I can't connect to the mysql database, I will have it after that I have to install the dependencies on NPM and ENV on the cpanel but I don't know how to do it please help me to solve the problem
.env code = DATABASE_URL="mysql://ouse6621_aidemoiapp:Bonjour2022#localhost:3306/ouse6621_aidemoiapp"
schema.prisma = // This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
I use GlassFish 5 with mysql-connector-java-8.0.13.jar
and CLASSPATH values:
C:\Program Files\glassfish5\glassfish\lib
C:\Program Files\glassfish5\glassfish\domains\domain1\lib
C:\Program Files\glassfish5\glassfish\domains\domain1\lib\ext
After several restarts of both the server and the laptop it still gives this error:
Ping Connection Pool failed for MySQL_sakila. Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource Please check the server.log for more details.
Properties
The issue is similar to this StackOverflow source but I have applied the answers there and none of them have helped.
What worked for me:
Datasource Classname: com.mysql.cj.jdbc.MysqlConnectionPoolDataSource
Two new "Additional Properties" to the JDBC Connection Pool :
useSSL = false
serverTimezone = UTC (this is not even true in my case, I am UTC+2)
Here one remark : when I installed MySQL instance, I expressly set it NOT to use SSL for the passwords from the option in the installer on the regarding page.
other "Additonal Properties " are :
password = myPass
databaseName = sakila
serverName = localhost
user = root
networkProtocol = jdbc
portNumber = 3306
.. and it succeeded
It worked for me too. Exellente! Although I used the
com.jdbc.jdbc2.optional.MysqlDataSource on Netbeans as my Datasource name but I think setting useSSL= false is real thing.
But I used com.mysql.cj.jdbc.MysqlConnectionPoolDataSource on glassfish server
I want to build a simple app that connects to remote MySQL server. However, I can't make it work.
import ballerina/io;
import ballerina/jdbc;
import ballerina/mysql;
endpoint jdbc:Client jiraDB {
host: "jdbc:mysql://DB-SERVER:3306/jira",
username: "jira",
password: "PWD",
poolOptions: { maximumPoolSize: 5 }
};
type Domain record {
string domain,
string jira,
};
function main(string... args) {
var ret = jiraDB->select("SELECT * FROM `domains`", ());
table domainTable;
match ret {
table tableReturned => domainTable = tableReturned;
error e => io:println("Select data from domains table failed: " + e.message);
}
while(domainTable.hasNext()) {
var domain = <Domain>domainTable.getNext();
match domain {
Domain d => io:println("Domain: " + d.domain);
error e => io:println("Error in get employee from table: "
+ e.message);
}
}
}
The structure of MySQL is not really important. I think it has to do with missing / wrongly used JDBC/MySQL library.
Do you please have any ideas how to make it work on Mac OS X ?
$ ballerina run hello.bal
error: ballerina/runtime:CallFailedException, message: call failed
at ..<stop>(hello.bal:5)
caused by error
at ballerina/jdbc:stop(endpoint.bal:66)
I'm using latest Mac OS X with:
$ ballerina --version
Ballerina 0.980.1
First, the latest ballerina version is 0.981.0. It would be great if you could use the latest version since it would include latest bug fixes and improvements.
In Ballerina, there is a generic jdbc client which can be used to connect to any database which has a jdbc driver. In addition, for mysql and h2 there are two clients implemented specifically for those two databases.
When connecting to mysql, you could either use the generic jdbc client or the mysql specific client. The recommendation is to use the mysql specific client.
In your code snippet, I can see you are using jdbc client. As Anoukh mentioned above, the endpoint configuration is incorrect.
Following is a sample configuration for generic jdbc client endpoint.
endpoint jdbc:Client testDB {
url: "jdbc:mysql://localhost:3306/testdb",
username: "user1",
password: "pass1",
poolOptions: { maximumPoolSize: 5 }
};
And following is a sample configuration of mysql client endpoint.
endpoint mysql:Client testDB {
host: "localhost",
port: 3306,
name: "testDB",
username: "user1",
password: "pass1",
poolOptions: { maximumPoolSize: 5 }
};
In order to use either of the clients, you need to copy the mysql jdbc driver to ${BALLERINA_HOME}/bre/lib.
Even after correcting your configuration and copying the driver, if you still face the issue, please check whether file named ballerina-internal.log is created where you are running your bal file and share. Also please share the mysql database and driver version you are using.
Have you copied the MySQL JDBC driver to the BALLERINA_HOME/bre/lib folder?
You can find the ballerina home using which ballerina command.
You can download the mysql jdbc driver from http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar
The issue might be in the jiraDB endpoint configurations. As per the API docs, the config for the URL of the database is to be given as url instead of host.
I was not able to connect to Mysql and I faced a driver instance error. I solved it! I'm not sure to post my answer at the good place but I think it will be a good resource to fix some problems with Mysql connections issues in Ballerina.
In my terminal : echo $BALLERINA_HOME
/Library/Ballerina/ballerina-0.990.2
Copy the good jar in the right place !
Go to : http://central.maven.org/maven2/mysql/mysql-connector-java/
I have downloaded the latest stable version (at the time of writing 8.0.15).
Copy the jar in $BALLERINA_HOME/bre/lib/
I had an error with a prior version.
Be careful that your jar have the right extension (the .jar not the repository with the same name).
Also be sure to have fulfilled the recommandations (see the doc of Oracle when installing a jar, i.e setting the classpath)
In your terminal, set the class path :
export CLASSPATH=$CLASSPATH:/Library/Ballerina/ballerina-0.990.2/bre/lib/mysql-connector-java-8.0.15
Then it will work !
I followed the steps trying to configure MySQL in WildFly. I have two questions for your help with:
1) I downloaded the mysql-connector-java-5.1.33-bin.jar and placed it under modules/system/layers/base/com/mysql/main/. Do I need to download the actual MySql? Or the connector jar is sufficient?
2) In creating a new data source in WildFly console, I was not able to create a new data source. Part of the information I need to fill in is a pair of user name and password to access the database. Where should I create this user name and password first? I am guessing this is where I got the problem from.
I got this error message when testing the connection in wildfly console:
Unexpected HTTP response: 500
Request
{
"address" => [
("subsystem" => "datasources"),
("data-source" => "mysqlDSPool")
],
"operation" => "test-connection-in-pool"
}
Response
Internal Server Error
{
"outcome" => "failed",
"failure-description" => "JBAS010440: failed to invoke operation: JBAS010447: Connection is not valid",
"rolled-back" => true
}
first you need to install Mysql server and a JDBC 4-compliant driver, normally all new JDBCs provided by Mysql.org are JDBC 4-compliant, find a platform independant one here, then you need to add a datasource here in this file standalone/configuration/standalone.xml or using this command
data-source add --name=myDataSource--jndi-name="java:jboss/datasources/myDataSource" \
--connection-url="jdbc:mysql://localhost:3306/myDB" \
--driver-name=h2 --user-name="myDB_Username" --password="myPassword"
username and password are those used to connect to Mysql database.
1) You need to download the jdbc-driver jar which, I think, is the connector jar. But please don't place it under modules/system/... but directly under modules since the system folder is reserved for internal modules that are delivered with the server.
2) Here is an example (configures an Oracle datasource):
/subsystem=datasources/jdbc-driver=OracleJdbcDriver:add(driver-module-name=oracle.jdbcaq,driver-name=OracleJdbcDriver)
/subsystem=datasources/data-source=OracleDS:add(jndi-name=java:jboss/datasources/OracleDS,enabled=true,jta=true,use-java-context=true,connection-url=jdbc:oracle:oci:#dbms:1523/DEV,driver-name=OracleJdbcDriver,min-pool-size=5,max-pool-size=100,user-name=username,password=password,prepared-statements-cache-size=100,exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter)