I had configured mssql as a user provided service in pcf. had created a java application with springboot and flywaydb for migration. When i try to deploy my java application into pcf it gives me the error "Caused by: org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password!". Had bind my app to the mssql service and restarted the application in pcf, but still the same error.
application.properties
spring.datasource.url=${vcap.services.db.credentials.jdbcUrl}
spring.datasource.username=${vcap.services.db.credentials.username}
spring.datasource.password=${vcap.services.db.credentials.password}
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
mssql configuration in pcf
uri : sqlserver://xxx:yyy#zzz:1433/db
username : xxx
password : yyy
expected : server should start without any issues and the tables should be created as mentioned in the migration sql file
actual : error "Caused by: org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password!".
Related
I am setting up an RestApiApplication.java and want to connect to a sqlite DB via URL
Now I have trouble setting up the resources via
application.properties file:
spring=
datasource=
driver-class-name=com.sqlite.jdbc.Driver
url=jdbc:sqlite:restApi.sqlite
username=root
password=
spring.jpa.hibernate.ddl-auto=create-drop
The terminal error in the IDE is:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
I am working in a Mac Environment with Mac OS Ver 12.5
IDE I am using is IntelliJ IDEA CE
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
For setting up the database I am using DataGrip and the Database itself with it setting seems to be fine.
LOOK at DataGrip setup here
Any hints are welcome!
Thank you very much!
I am trying to connect Azkaban ( A job scheduler for hadoop) with my local mysql. The configiration file of azkaban looks like:
database.type=mysql
mysql.port=3306
mysql.host=localhost
mysql.database=azkaban
#Changed by Prakhar for azkaban , Azkaban
mysql.user=root
mysql.password= [ Password of mysql ]
My MySql has a database named "azkaban" and i am able to login mysql using command:
./mysql -u root -p
Also mysql is working on port 3306, which i have verified.
Still i am unable to connect to mysql. The logs of azkaban looks like this:
2020/04/11 22:38:05.584 +0530 ERROR [MySQLDataSource] [Azkaban] Failed to find write-enabled DB connection. Wait 15 seconds and retry. No.Attempt = 1
java.sql.SQLException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)
at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2294)
at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2039)
at azkaban.db.MySQLDataSource.getConnection(MySQLDataSource.java:76)
at org.apache.commons.dbutils.AbstractQueryRunner.prepareConnection(AbstractQueryRunner.java:175)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:286)
at azkaban.db.DatabaseOperator.query(DatabaseOperator.java:68)
at azkaban.executor.ExecutorDao.fetchActiveExecutors(ExecutorDao.java:53)
at azkaban.executor.JdbcExecutorLoader.fetchActiveExecutors(JdbcExecutorLoader.java:266)
at azkaban.executor.ExecutorManager.setupExecutors(ExecutorManager.java:223)
at azkaban.executor.ExecutorManager.<init>(ExecutorManager.java:131)
at azkaban.executor.ExecutorManager$$FastClassByGuice$$e1c1dfed.newInstance(<generated>)
at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111)
at
Few pointers that might help you to resolve the issue.
Please check the version of MySQL installed vs the MySQL client mentioned in the Gradle file used to build Azkaban
Preferably use MySQL 5.x version
Make sure to install the compatible client version
Also, create the Mysql tables in the database before starting the web executor
Hello guys !
It's my first so I will try to make the best that I can.
I want to create an app which is running with Springboot framework and I would like to connect it to a docker container which embeds MySQL (but the spring boot app is not running on docker)
So I have followed this post
I have made my docker-compose:
db:
image: mysql
ports:
- '3306:3306'
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_DATABASE=users
volumes:
- ../data:/var/lib/mysql
and I run it with this command :
docker-compose run --service-ports db
All is fine, so now I change my application.properties on spring boot :
## Server Properties
server.port= 5000
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url= jdbc:mysql://127.0.0.1:3306/users?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
spring.datasource.username= root
spring.datasource.password= secret
## Hibernate Properties
#The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto = update
## Hibernate Logging
logging.level.org.hibernate.SQL= DEBUG
## Jackson Properties
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS= false
spring.jackson.time-zone= UTC
But When I run my app, I have this error :( :
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
I'm on MacOS...
I tried to follow callicoder's course ...
https://www.callicoder.com/spring-boot-spring-security-jwt-mysql-react-app-part-1/
Thanks for your help :)
The problem is that the db container is not running on localhost but rather inside a mini Linux VM since you are on a MAC.
Thus to connect to the database you need to use the IP address of the machine where the container is running. To do that run the command docker-machine ip default. This will return the IP address which you would use in the connection url rather than localhost:
spring.datasource.url= jdbc:mysql://<docker-machine-ip>:3306/users?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
I have just installed Wildfly and I tried to connect it :
\wildfly-11.0.0.Final\bin>jboss-cli.bat -c
But gives me follow error :
Failed to connect to the controller: The controller is not available
at localhost:9990: java.net.ConnectException: WFLYPRT0053: Could not
connect to remote+http://localhost:9990. The connection failed:
WFLYPRT0053: Could not connect to remote+http://localhost:9990. The
connection failed: Connection refused: no further information
I tried a lot of solutions but it's not working for me.
With Widlfly running, i.e. (standalone.bat), use the --controller option to define where it is:
jboss-cli.bat -c --controller=localhost:9990
Got the same error on wildfly version 16
Error
Failed to connect to the controller: The controller is not available at localhost:: java.net.ConnectException: WFLYPRT0053: Could not connect to remote+http://localhost:. The connection failed: WFLYPRT0053: Could not connect to remote+http://localhost:. The connection failed: Connection refused
And following done and resolved successfully
Step 01
Comment (or you can remove) following line from /bin/jboss-cli.xml
default-protocol use-legacy-override="true">remote+https</default-protocol
Correct protocol Ex:
<default-protocol use-legacy-override="true">remote+http</default-protocol>
<!-- The default controller to connect to when 'connect' command is executed w/o arguments -->
<default-controller>
<protocol>remote+http</protocol>
<host>localhost</host>
<port>9990</port>
</default-controller>
Step 02
In my case i have alredy created a Administrative user hence, I have statup the CLI with following commnad
./jboss-cli.sh --user="<user>" --password="<password>" --controller=remote+http:<your IP>:<port> --connect
Example :
./jboss-cli.sh --user="Admin" --password="Password" --controller=remote+http://19.199.115.172:9990 --connect
Make sure your wildfly is up and running. If you have used different port for the admin console it should be added .
Jboss must be running while doing this. I was trying to do this while my jboss was not up n running... then i got this error message. So boot up jboss and try again.
The most common case is that there is a mismatch between the default controller defined in jboss-cli.xml and the management port, configured in the standalone.xml/domain.xml. Out of the box, they should converge on localhost:9990. Therefore, verify if you changed any of the two files. Other than that, it could be a firewall/network issue.
See also: Cannot connect to WildFly with CLI
I'm unable to get spring boot to automatically load my database schema when I start it up.
I follow this example: https://spring.io/guides/gs/accessing-data-mysql/#scratch
Here is my application.properties:
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://localhost:3306/sakila
spring.datasource.username=root
spring.datasource.password=root1
sakila it is a default database included in mysql
enter image description here
Error:
Unable to create initial connections of pool