com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ''. ClientConnectionId: - sql-server

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

Related

NodeJS OracleDB connection string

I am running Oracle XE 21c in a Docker container and I can connect to it with a JDBC thin connection using the JDBC url jdbc:oracle:thin:#localhost:1521:XE using the SYSTEM account. I can also log into the terminal Docker instance and connect to the database fine.
When I try to connect to it using NodeJS OracleDB example code described here:
https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html, I cannot get the client to connect using either:
connection = await oracledb.getConnection({
user : "hr",
password : mypw
connectString : "localhost/XEPDB1"
});
or
connection = await oracledb.getConnection({
user : "SYSTEM",
password : "MyPassword",
connectString : "localhost/XE"
});
I get an error ORA-01017: invalid username/password; logon denied.
I can connect to Oracle XE using sqlplus either by logging into the Docker container or from the host Mac using:
sqlplus SYSTEM/Password#localhost:1521/XE
if I change the nodejs code to:
const connection = await oracledb.getConnection({
//user: "SYSTEM",
//password: "Password42",
//connectString: connectionURI.url
connectString: "SYSTEM/Password#localhost:1521/XE"
});
I get the error:
ORA-12154: TNS:could not resolve the connect identifier specified
Any ideas why I can connect with sqlplus but not NodeJS OracleDB?

Issue Installing and Configuring the ODBC Driver for macOS

I can successfully access Snowflake via snowsql, and a browser using the same credentials. However, those credentials do not work with the Driver as laid out in odbc-mac guide. When I test according to "Step 3: Test the ODBC Driver" I get the following eperience:
$ "/Library/Application Support/iODBC/bin/iodbctest"
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.1521.0607
Enter ODBC connect string (? shows list): dsn=SnowflakeDSII;pwd=[pwd]
OOB curl_easy_perform() failed: Problem with the SSL CA cert (path? access rights?)
OOB curl_easy_perform() failed: Problem with the SSL CA cert (path? access rights?)
OOB curl_easy_perform() failed: Problem with the SSL CA cert (path? access rights?)
OOB curl_easy_perform() failed: Problem with the SSL CA cert (path? access rights?)
OOB curl_easy_perform() failed: Problem with the SSL CA cert (path? access rights?)
1: SQLDriverConnect = [Snowflake][DSI] An error occurred while attempting to retrieve the error message for key 'SFRestRequestFailed' with message parameters ['[host]:443/session/v1/login-request?requestId=[id]&request_guid=[guid]&databaseName=[db_name]&warehouse=[wh]&roleName=[role]', 'CURLerror (curl_easy_perform() failed) - code=77 msg='Problem with the SSL CA cert (path? access rights?)' osCode=2 osMsg='No (-1) SQLSTATE=HY000
1: ODBC_Connect = [Snowflake][DSI] An error occurred while attempting to retrieve the error message for key 'SFRestRequestFailed' with message parameters ['[host]:443/session/v1/login-request?requestId=[id]&request_guid=[guid]&databaseName=[db]&warehouse=[wh]&roleName=[role]', 'CURLerror (curl_easy_perform() failed) - code=77 msg='Problem with the SSL CA cert (path? access rights?)' osCode=2 osMsg='No (-1) SQLSTATE=HY000
my odbc.ini file is
[ODBC Data Sources]
SnowflakeDSII = Snowflake
[SnowflakeDSII]
Server = [host account].[aws region].snowflakecomputing.com
UID = [user]
Role = [role]
Database = [db]
Warehouse = [warehouse]
Driver = /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib
Also...
I installed the driver: snowflake_odbc_mac_arm64-2.25.0.dmg
I had to manually mkdir universal and cp lib/libSnowflake.dylib lib/universal/libSnowflake.dylib
(And the error files too)
Thank you for your time!
Update
Also note the system couldn't find the following error files:
"exceptionMessage": "CURLerror (curl_easy_perform() failed) - code=77 msg='Problem with the SSL CA cert (path? access rights?)' osCode=2 osMsg='No such file or directory'",
"request": "https://[host].us-east-1.snowflakecomputing.com:443/session/v1/login-request?requestId=b5ebf406-989e-4aab-a043-6b4b656961cd&request_guid=8b68691f-db12-44c3-9a91-1fc685cd87a5&databaseName=[db]&warehouse=[wh]&roleName=[role]",
"sqlState": "HY000"
"/opt/snowflake/snowflakeodbc/lib/universal/en-US/SFMessages.xml"
"/opt/snowflake/snowflakeodbc/lib/universal/SFMessages_en-US.xml"
So I touched them, but then the error said they were 'empty'
The issue was that many of the files that the system needs to be in /lib/universal are not there.
The solution is to either sym link, or move them from /opt/snowflake/snowflakeodbc
for example:
# I found
/opt/snowflake/snowflakeodbc/lib/universal/en-US/SFMessages.xml
in
/opt/snowflake/snowflakeodbc/ErrorMessages
Also
/opt/snowflake/snowflakeodbc/lib/cacert.pem
# needed to be moved to
/opt/snowflake/snowflakeodbc/lib/univeral/cacert.pem
Thank you, #Sergiu for the logging guidance!

ODI Start agent fail

When I try to start odi agent with this command:
C:\ORACLE_HOME\user_projects\domains\ODIDOMAIN\bin>agent -NAME=OracleDIAgent1 -PORT=20910
This error is shown:
ODI-1404: Agent OracleDIAgent1 start failure: an authentication error occurred while connecting to the master repository.
Caused by: oracle.odi.core.security.BadCredentialsException: ODI-10199: Incorrect ODI username or password.
the full text is:
2020-11-04 07:17:58.676 NOTIFICATION New data source: [DEV_ODI_REPO/*******#jdbc:oracle:thin:#//10.1.5.66:1521/ORCL66]
2020-11-04 07:18:04.599 NOTIFICATION ODI-1128 Agent OracleDIAgent1 is starting. Container: STANDALONE. Agent Version: 12.2.1. Port: 20910. JMX Port: 21910.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Allowing : 127.0.0.1,10.1.5.66,127.0.0.1
2020-11-04 07:18:10.088 WARNING odi.core.security.SecurityManager.loadAuthenticationMode found the authMode:mUsingLDAPAuthentication: false,mUsingIDCSAuthentication:false,indExternalAuth:null.
2020-11-04 07:18:10.420 ERROR ODI-1131 Agent OracleDIAgent1 encountered an error: ODI-1404: Agent OracleDIAgent1 start failure: an authentication error occurred while connecting to the master repository. Caused by: ODI-10199: Incorrect ODI username or password.
2020-11-04 07:18:10.420 WARNING ODI-1404: Agent OracleDIAgent1 start failure: an authentication error occurred while connecting to the master repository.
Caused by: oracle.odi.core.security.BadCredentialsException: ODI-10199: Incorrect ODI username or password.
2020-11-04 07:18:10.435 WARNING unavailable
2020-11-04 07:18:10.435 WARNING Failed startup of context o.o.#17125ea9{/oraclediagent,file:/C:/ORACLE_HOME/user_projects/domains/ODIDOMAIN/system_components/ODI/OracleDIAgent1/work/webapp/,STARTING}{file:/C:/ORACLE_HOME/odi/agent/lib/./oraclediagent.war}
2020-11-04 07:18:10.435 WARNING FAILED o.o.#17125ea9{/oraclediagent,file:/C:/ORACLE_HOME/user_projects/domains/ODIDOMAIN/system_components/ODI/OracleDIAgent1/work/webapp/,UNAVAILABLE}{file:/C:/ORACLE_HOME/odi/agent/lib/./oraclediagent.war}: javax.servlet.ServletException: ODI-1404: Agent OracleDIAgent1 start failure: an authentication error occurred while connecting to the master repository.
Caused by: oracle.odi.core.security.BadCredentialsException: ODI-10199: Incorrect ODI username or password.
2020-11-04 07:18:10.471 WARNING FAILED org.eclipse.jetty.server.Server#77bca6d6: javax.servlet.ServletException: ODI-1404: Agent OracleDIAgent1 start failure: an authentication error occurred while connecting to the master repository.
Caused by: oracle.odi.core.security.BadCredentialsException: ODI-10199: Incorrect ODI username or password.
2020-11-04 07:18:10.472 ERROR ODI-1443 Error while starting agent : ODI-1404: Agent OracleDIAgent1 start failure: an authentication error occurred while connecting to the master repository.
Caused by: oracle.odi.core.security.BadCredentialsException: ODI-10199: Incorrect ODI username or password.
2020-11-04 07:18:10.503 ERROR ODI-1404: Agent OracleDIAgent1 start failure: an authentication error occurred while connecting to the master repository.
Caused by: oracle.odi.core.security.BadCredentialsException: ODI-10199: Incorrect ODI username or password.
2020-11-04 07:18:10.503 ERROR javax.servlet.ServletException: ODI-1404: Agent OracleDIAgent1 start failure: an authentication error occurred while connecting to the master repository.
Caused by: oracle.odi.core.security.BadCredentialsException: ODI-10199: Incorrect ODI username or password.
The ODI version is 12 and node manager and weblogic is starting correctly.
As the error message states, the ODI username or password that was provided when configuring the agent is incorrect.
To reconfigure the agent and set the correct credentials on Windows :
execute config.cmd in C:\ORACLE_HOME\oracle_common\common\bin
click next on all the steps except the ODI Server Configuration page where you can type the password
start the agent
More info in Oracle Support Doc ID 2386816.1
Its not the problem with SUPERVISOR credentials. if you have multiple Agents in various servers you may face this issue. only one agent may fail out of n.
Copy the ODI_MASTER_ENCODED_PASS value to the expected location within the odiparams.sh file on the system where the agent is not starting.
The odiparams.sh file can be found in:
$ODI_HOME\oracledi\agent\bin

SqlException (0x80131904): Cannot open database "DBName" requested by the login

I have the following connection string in ASP.NET Core, but I get the following error:
Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open
database "DBName" requested by the login. The login failed. Login
failed for user 'admin-PC\admin'.
In SQL log
Error: 18456, Severity: 14, State: 38. and Login failed for user
'admin-PC\admin'. Reason: Failed to open the explicitly specified
database 'DBName'. [CLIENT: ]
"AllowedHosts": "*",
"ConnectionStrings": {
"CoreConnection": "server=.;Database=DBName;Trusted_Connection=True;MultipleActiveResultSets=true;"
How can I make it work?
Maybe you deleted your database?
I had the same problem. So, if you have created migration, just run
update-database in your Package Manager Console.

not attempt to authenticate using SASL (unknown error)

I am trying to setup zookeeper on ec2 two instances. as given here and here.
I am trying to run zookeeper which fails with an error:
command: bin/zkCli.sh -server localhost:2181
> 2015-03-15 00:22:35,644 [myid:] - INFO [main:ZooKeeper#438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher#3ff0efca
Welcome to ZooKeeper!
2015-03-15 00:22:35,671 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread#975] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2015-03-15 00:22:35,677 [myid:] - WARN [main-SendThread(localhost:2181):ClientCnxn$SendThread#1102] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
[zk: localhost:2181(CONNECTING) 0] 2015-03-15 00:22:36,796 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread#975] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2015-03-15 00:22:36,797 [myid:] - WARN [main-SendThread(localhost:2181):ClientCnxn$SendThread#1102] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
zoo.cfg as bellow
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/var/lib/zookeeper
clientPort=2181
server.1=localhost:2888:3888
server.2=<My ec2 private IPs>:2889:3889
also I have created myId file as on both ec2 instances - /var/lib/zookeeper/myid
I also tried to edit /ect/hosts file but still facing the same issue.
also how I can start both of the zookeeper instances by 1 command?
Note: Server get started successfully if I tried with bin/zkCli.sh start command.
Thanks in advance!
look zk log zookeeper.out,if there have connection limit error, configure the following to zoo.cfg.
# the maximum number of client connections.
# increase this if you need to handle more clients
maxClientCnxns=60
This is temporary error , for mine after some time , It gone away :-
This is my zoo.conf file ::-
Dir=../data
clientPort=2181
tickTime=2000
initLimit=5
This error occurred when I forgot to run% ZOOKEEPER_HOME% \ bin \ zkserver.cmd
By running, the problem has been resolved.
Correct this property on the server.properties
default would be localhost change it to match the zookeeper server starup ip and port
zookeeper.connect=0.0.0.0:2181

Resources