SQL Server 2008 connection issues - java

So I'm working on a project using a SQL Server 2008 database. It uses Java with Hibernate. I was doing some work on it last week, it was working (relatively) fine. I came back to it today and all of the sudden Hibernate can't login or connect to the database. I suspect the problem is in SQL Server because I tried connecting to it with JDBC but that didn't work either.
Server authentication is set to "SQL Server and Windows Authentication mode"
my users "dummy" and "root" have "Grant" check on all explicit permissions.
The username and password I enter are correct. I know this because I can log in o SQL Server Management Studio with those logins and run queries.
The database is on a Windows XP virtual machine and I'm using Eclipse on my host machine. I have Port Forwarding and everything set up with Oracle VirtualBox (like I said, it was working fine last week).
Any suggestions?
--EDIT--
See the comments below the original post
---EDIT---
I made a discovery. My Java project is not even getting connected with the SQL Server. When I fail a log in with a .udl test, a log message is created for the failed login. But whenever I fail to login using my Java project on my host machine, there are logs created.
I should also point out that I can connect to a MySQL database running on the same VM and run queries on it just fine.
Is there something wrong with this URL String? "jdbc:sqlserver://192.168.56.1:1433;databaseName=MLB;user=dummy;password=123"
I can confirm that the IP Address, Port number, database name, username, and password are all correct.

I figured out the answer myself. I had install SQL Server 2014 on my host machine and somehow that conflicted with some settings somewhere. Once I unistalled SQL Server 2014 from my host machine all of my problems went away.

Related

Connectng SQL Server 2012 with Java using JDBC

I am using sqljdbc4.jar for connecting SQL Server 2008 with java application using Windows authentication. Everything works perfectly up to date until I tried to run the same code with SQL Server 2012.
After research, I came to know that I need to enable the TCP/IP. But my problem is, my applications will be distributed to users in the form of .EXE and users will install the application themselves. Also, all users will have the SQL SERVER 2012 pre-installed, my application is not supposed to install the sql server.
Now my question is, how can I connect to SQL server without enabling TCP/IP manually? I heard about shared memory protocol also, but not sure how its connection string will look like?
I am using below connection url till SQL Server 2008:
jdbc:sqlserver://localhost;instanceName=SQLServer12;databaseName=Test;integratedSecurity=true;SelectMethod=direct;responseBuffering=adaptive
Please give your suggestions so I can try it here. Thanks in advance.
Try adding the property Network Library=dbmslpcn; OR Net=dbmslpcn; to the connection string for Shared Memory. The default value is dbmssocn (TCP/IP).
Network Library: The network library used to establish a connection to an instance of SQL Server. The corresponding network DLL must be installed on the system to which you connect. If you do not specify a network and you use a local server (for example, "." or "(local)"), shared memory is used.
I got this from: https://www.connectionstrings.com/all-sql-server-connection-string-keywords

'Communications link failure The last packet sent…' when connecting to MySQL with Java

I have deployed my application and distributed onto a client windows computer. I have disabled my antivirus and windows firewall but why do i still get this error 'Communications link failure The last packet sent…' when connecting to MySQL?
I have successfully installed Java version 8. Do i have to also install Xampp on the client windows computer for the application to work?
Issue lies on the IP configuration, so first look for your IP address then
on your client's computer, put your IP. It would have helped if you sent the code on your computer and on your client's computer. On your computer you may have this, and it will work fine.
jdbc:mysql://localhost:3306/test
But on your client's computer since they are connecting to a database on your machine, it will be like this:
jdbc:mysql://xxx.xxx.x.x:3306/test
Check on your computer whether the MYSQL server is running.

Establish MS SQL 2008 connection with JDBC using domain credentials

I have three servers, App Server, Domain Controller and SQL Server. All of them are connected trough the local network.
What I am trying to accomplish is to successfully connect my app to the database using the credentials of an authorized domain user (ex: dom\dbadmin).
When I connect locally using those credentials, it works.
When I run the next code trough CMD on the APP Server with the right credentials and local IP, it works!
RUNAS /user:dom\dbadmin /netonly "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe"
But when I try to connect with my app to the database with the following connection string it does not connect.
jdbc:sqlserver://10.20.30.110\MSSQLSERVER;databaseName=dBase;user=dom\dbadmin;password=!8899#te$t;
I have successfully made a connection to a identical DB but with SQL credentials and a remote ip and it works.
Am I doing something wrong? Or is it just not possible to make a connection with JDBC and domain credentials?
As far as I know - for passthrough authentication to work (SSPI in connection string) - you'll have to allow the domain controller to make the decision to allow you in with your credentials or not. In order to make this decision the controller will reply on your windows authentication with all imposed security restriction on computers within that domain. If you are logged on a computer as CORP\UserName then SSMS will not allow you to connect as someone else such as MyDomain\OtherUser. That is even if you know the correct password.
If you need an application to connect to an SQL Server you'll probably have to enable mixed authentication on the SQL Server and then generate an application password (not relying on Windows authentication).

Testing MySQL database on LAN client

I am attempting to create a MySQL DB and Java client app for my home network. I haven't really had any experience with MySQL other than PHPMyAdmin for a website backend (also have used SQLite). I have downloaded the full MySQL installation and a test DB from the MySQL website. On the server machine I successfully connected to the DB as root. Not a difficult task.
Now I want to connect to the DB from my client PC, just to check I can. Eventually I will use the JDBC driver to connect from my Java client app, but before that I just want to check I can connect.
How should I do this? SHould I just install the MySQL command line program onto the client PC?
EXTRA INFO: forgot to add, I'm using Windows 7 on all my machines.
Yes, you could install the MySQL to get MySQL command line program and connect with it, but also you can use another MySQL client tool like PHPMyAdmin, dbForge Studio for MySQL or another one.
To connect from remote host you should create special accout for it, e.g. - 'user_name'#'your_host_name'. Find more information here -
Specifying Account Names
Account Names and Passwords

TomCat Issue: tomcat as windows service makes sql authentication to fail whereas if tomcat is run normally conn to db is successful

we hav a java app running on tomcat
backend is sql server configured for windows authentication
we are runnning tomcat as a windows service
we are not able to connect to sql db bcoz tomcat is used as windows service.
guess, its taking different userid and pass for which sql server windows authentication fails.
however, if we run tomcat normally (not as windows service), connection to db getting successful, but we cannot run tomcat normally as we want it to run forever. if we run tomcat normally, it shuts down when that particular user who started tomcat logs off as his
session expires.
Try to configure tomcat service to log on as some real account not as Local system account.
Why don't you use Mixed authentication mode for SQL server instead of Windows Authentication because as per SQL Server's documentation using Local System Account is not recommend for security considerations.
In Mixed mode make a special user for your application and give the rights accordingly. Then use that user/pass in your connection string.

Categories

Resources