I installed SQL Server 2019 Developer Edition, but I have connection problems
My application.yml
spring:
jpa:
hibernate:
dialect: org.hibernate.dialect.SQLServerDialect
ddl-auto: none
temp:
use_jdbc_metadata_defaults: false
datasource:
url: jdbc:sqlserver://localhost;databaseName=mydb;encrypt=true;trustServerCertificate=true;integratedSecurity=false;
username: MY_USER
password: MY_PASSWORD
I checked the password twice, firewall is OK, TCP Connection are enabled. What is missing ?
Is my spring configration wrong or could it be something on SQL Server
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'MY_USER'. ClientConnectionId:2ce05ca6-9bcf-40e2-b324-4b395089c785
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:265) ~[mssql-jdbc-10.2.1.jre17.jar:na]
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:299) ~[mssql-jdbc-10.2.1.jre17.jar:na]
... 21 common frames omitted
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100) ~[hibernate-core-jakarta-5.6.9.Final.jar:5.6.9.Final]
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) ~[hibernate-core-jakarta-5.6.9.Final.jar:5.6.9.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:138) ~[hibernate-core-jakarta-5.6.9.Final.jar:5.6.9.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-jakarta-5.6.9.Final.jar:5.6.9.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) ~[hibernate-core-jakarta-5.6.9.Final.jar:5.6.9.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ~[hibernate-core-jakarta-5.6.9.Final.jar:5.6.9.Final]
... 38 common frames omitted
Related
I'm trying to connect to microsoft sql server using 8.2 version of jar.
It works fine when I'm using the same username, password in DBeaver. I'm not using any additional options in the connection string of DBeaver. I'm using the type SQLServer Authentication. It gets connected in DBeaver but I'm not able to open a connection via Scala repl.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")
val props=new java.util.Properties
props.put("user","")
props.put("password","")
// URL : jdbc:sqlserver://host:port // No additional options like in DBeaver
DriverManager.getConnection("url",props)
Error:
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'USERNAME'. ClientConnectionId:CONNECTIONID
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:283)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:129)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:37)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:5173)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3810)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:94)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3754)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7225)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3053)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2562)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2216)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2067)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1204)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:825)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
... 47 elided
I'm facing the following problem in my application that after a while running it starts to show the following warn.
HikariPool-1 - Failed to validate connection ConnectionID:19 ClientConnectionId: cea9b6e9-baac-495d-8f9b-08723893b6d9 (The connection is closed.). Possibly consider using a shorter maxLifetime value.
I already set the maxLifetime property to 600000 in my application.yml but the problem still persists.
Do I have other Hikari settings to configure?
I'm using spring boot 2.5.12 and data base Sql Server 2017
application.yml
spring:
main:
allow-circular-references: true
datasource:
hikari:
maxLifetime: 600000
url: jdbc-url
username: userName
password: passwaord
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
jpa:
open-in-view: false
properties:
hibernate:
dialect: org.hibernate.dialect.SQLServer2012Dialect
proc:
param_null_passing: true
show-sql: false
data:
web:
pageable:
default-page-size: 20
I have Grails 3.3.11 application, and I'm trying to deploy it on flexible Google App Engine, however, I have some errors mainly produced from connecting to Google cloud SQL, I made MySQL 5.7 instance on it and able to access it from my IDE and while I run the application locally,I searched for some solutions for theses errors but unfortunately, nothing worked for me, here are the exceptions
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method 'methodValidationPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastoreServiceRegistry': Cannot resolve reference to bean 'hibernateDatastore' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to check JDBC Connection auto-commit in preparation for DDL execution
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
at
org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:46)
"
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:299)
here are the production configurations in application.yml
dataSource:
dbCreate: create-drop
driverClassName: com.mysql.jdbc.Driver
dialect: org.hibernate.dialect.MySQL5Dialect
username: myUsername
password: myPassword
url: jdbc:mysql://DBIP:3306/CusOrderIns
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2
build.gradle
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.15.1"
classpath "org.grails.plugins:hibernate5:${gormVersion - ".RELEASE"}"
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.2'
}
}
provided "org.springframework.boot:spring-boot-starter-jetty"
// provided "org.springframework.boot:spring-boot-starter-tomcat" //commented
App engine config in src\main\appengine\app.yaml
runtime: java
env: flex
runtime_config:
jdk: openjdk8
server: jetty9
resources:
cpu: 2
memory_gb: 5
disk_size_gb: 10
manual_scaling:
instances: 1
App engine service account roles in Google IAM:
Cloud SQL Admin
Cloud SQL Client
Cloud SQL Editor
Cloud SQL Instance User
Editor
Cloud Run Admin
Anything missed or not configured probably?
I'm following this Google Cloud Community documentation about Deploy a Grails app to App Engine flexible environment. If you are still unable to connect using IP address of Cloud SQL, try using the Instance Connection Name of your Cloud SQL instance in url of dataSource and additional MYSQL dependencies in build.gradle:
application.yml
production:
dataSource:
dbCreate: update
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://google/[DATABASE_NAME]?socketFactory=com.google.cloud.sql.mysql.SocketFactory&cloudSqlInstance=[INSTANCE_NAME]&useSSL=true
username: root
password: password
For [DATABASE_NAME], use the database name you used when you created the database.
For [INSTANCE_NAME], use your instance name, which is visible in your Cloud SQL instance details.
Added in build.gradle:
runtime 'mysql:mysql-connector-java:8.0.16'
runtime 'com.google.cloud.sql:mysql-socket-factory-connector-j-8:1.0.14'
I have a problem with connecting my database online.
My site is hosted on one server, and connects to a remote database that is on another server.
But it sends me the following error:
SQLSTATE [HY000] [2002] Connection refused Error
I did, however, put the exact connection information .. I do not understand why the connection is refused ..
parameters.yml:
parameters:
database_host: **.**.**.**
database_port: 3306
database_name: zip
database_driver: pdo_mysql
database_user: root
database_password: null
mailer_transport: smtp
mailer_host:
mailer_user:
mailer_password:
secret: d87fdb6ecf4089df33360b187388e33c34e12f85
I thank you in advance
Make sure the user/password are the right ones. You can use the mysql command line cli to try to connect.
I copied a source code from github, and then I install ruby,rails,mysql...,which are necessary!
this is the config/database.yml :
common: &common
adapter: mysql2
encoding: utf8
reconnect: true
# socket: /var/run/mysqld/mysqld.sock
common settings for any development databases
devel_common: &dev
host: localhost
username: root
password: wjn_123
common settings for all test databases
tst_common: &tst
host: localhost
username: root
password: wjn_123
common settings for all integration databases
int_common: &remote
host: localhost
username: root
password: wjn_123
.......
then I execute "rake eol:db:recreate RAILS_ENV=development" and there is no exception.but when I execute "rake eol:db:populate" and it gives me this :
Rebuilding BHL ...
Error accessing http:// localhost :8983/solr/bhl/update
"Connection refused - connect(2)"
.....
rake aborted!
Connection refused - connect(2)
/usr/local/rvm/gems/ruby-1.9.3-p392#upgrade/gems/webmock-1.8.11/lib/webmock/http_lib_adapters/net_http.rb:98:in request'
/usr/local/rvm/gems/ruby-1.9.3-p392#upgrade/gems/webmock-1.8.11/lib/webmock/http_lib_adapters/net_http.rb:116:instart_without_connect'
/usr/local/rvm/gems/ruby-1.9.3-p392#upgrade/gems/webmock-1.8.11/lib/webmock/http_lib_adapters/net_http.rb:131:in `start'
so how can I solve the problem .
and I did not install jdk/jre . is that the reason?
Do you think it might have anything to do with the issue mentioned by Houen in http://railscasts.com/episodes/278-search-with-sunspot?view=comments ?