Strange situation regarding connection to SQL Server with JDBC - sql-server

I have an application that I have developed 2 years ago that stopped working due to not be able to connect to a remote SQL Server 2008 anymore, and I can't figure it out why this is happening.
This is the situation: I have a desktop where I have jdk1.6.0_31 and I developed a small 'helloworld' like application to test the connection to this remote SQL Server, even with the firewall off I can't make it connect. Still on this desktop I have Visual Studio where I'm able to connect to this SQL Server (so firewall is not the problem I guess).
I have a laptop where I tested this 'helloworld' JDBC app, and on this laptop the application works, and I just copied the app from the desktop to the laptop.
I also copied the app to my virtual server (that hosts the application that I developed 2 years ago) and there this 'helloworld' app does not work also, with firewall on or off, it doesn't matter.
So I'm wondering, what in the world could be leading to such a strange situation? JDBC on desktop does not work, but through visual studio it does, JDBC on laptop works, and JDBC on virtual server does not?? I'm really confused about this. I have been struggling with this for a week already. And that's why I really need your help people!!
Best regards and thanks in advance!
Bruno

I expect this is as simple as a connection string issue. The format for a connection string might change for different languages (Java vs C#). Can you please post the connection string you are using -- rename constants of course -- I just want to see the format you are using.

Related

SQL Server Remote Connection on Centos 7 Increddibly slow

I have an instance of SQL Server running on a Centos 7 VPS together with an application running on .net core 2.2.
I tried running the application on a separate VPS instance remotely connecting to the SQL Server VPS. But the queries where running really really slow. Like 100-500 times as slow to be precise.
I've also noticed that as of recently (it didn't use to) MSSMS also hangs for a bit each time I right click anything in the Object Explorer.
The connection string looks like the following:
Server=(IP of the VPS running SQL Server);Database=master;User Id=(username); Password=(password);
Any suggestions on what to do?
I figured out that the issue was resolved by using servers geographically closer to each other.

Is A Driver For SQL Server Corrupt, And How To Fix It If So?

OK, I'm at wit's end here (not like I have many to start with, but that's a different story!). So (sigh)...
Somewhere along the line I get the distinct feeling that one or more of my database drivers have been corrupted or something, and I don't know how to fix the issue without a reinstall of Windows, which would be crazy. Here's the issue:
I am working on several web site projects, and I've been using Visual Studio 2015 Community and SQL Server 2014 Developer at home, with SQL Server Management Studio as the tool of choice for working with the databases, on a Windows 10 64-bit box. I've been developing code locally, and for the last couple weeks I haven't had need to connect to the (eventual) production SQL Server databases on my hosting provider's servers. The last time I connected (maybe two weeks ago) to them everything was fine and dandy, and I'd not had any issues before then with connectivity either.
Yesterday I needed to connect, and so I launched SSMS to sign in to the database. Instead of connecting, I got the error message about "network path not found", meaning SSMS couldn't find the database server. After several retries, I attempted to connect using Visual Studio's Server Explorer window, with the same resulting error message.
I tried to PING the server and was successful. I got a TELNET connection as well to port 1433, so the server name's correct, and I was able to resolve the name to the right IP. Still, I cannot make a DB connection to the remote databases.
I followed all of the suggestions for this basic issue, including turning off Windows Firewall, and I even turned off my cable modem's firewall, just to test whether it was something there. Still no joy.
As the ultimate step, I uninstalled SQL Server, SSMS, Visual Studio, and all of the accompanying bits, plus I deleted all of the folders for Visual Studio and SQL Server, to ensure everything I could find to delete was gone.
I opened a command prompt and ran cliconfg to make sure named that both TCP and named pipes were enabled, and they were.
I installed LinqPad after a reboot just to see if now I could connect, and still nothing.
Interestingly, I changed the connection string in the web.config file for my ASP.NET web site project on the local IIS box to point to the remote server's database, and it works.
So, now I have NO EARTHLY CLUE what's going on with my local machine that could be causing this. I've now spent almost two complete days on this. I haven't reinstalled SQL Server, SSMS or Visual Studio yet, but something's still not right that I can't get to the bottom of. Reinstalling Windows is not really an option if I can avoid it.
The question is, has anyone else run across something like this, and how can it be diagnosed or fixed?
To test connectivity try this
1. Create a blank text file in a folder
2. Rename the extensión to .udl to the text file (exmanple New textfile.udl)
3. Double click on New textfile.udl
The .udl file will show you input connection paremeters, fill them and click on Test connection. This can help you to test your drivers and SQL Server's
Interestingly, after two maddening days of pulling my hair out, I discovered that the .NET Data Provider For SQL Server was corrupted, evidently by a virus that made it past my AV software and was very stealthy, because the thing it affected was the SQL Server drivers.
The way I figured this out was to use the OLEDB data provider in Visual Studio to connect successfully to the remote database, which worked perfectly.
The fix to this was to run different AV software, which found and removed the virus, then I reinstalled SQL Server and Visual Studio, and it all works like a charm again!

App not working on other PC without SQL Server

I have created an app in Visual Studio using VB.Net and SQL Server database and the app is running fine on my PC but when I use this app on another PC it runs fine but wherever is database required it gives me error. Please let me know do I need to install SQL Server on those PC where I want to use this app? Or is there any other alternate way?
Please help I'm a beginner at programming.
It sounds like your application is using the SQL Server Native Client for its connections. You can read more about it here: https://msdn.microsoft.com/en-us/sqlserver/aa937733.aspx
In short, you'll need to have people install the client on their machine, or use a different method to connect to the database.

Can a WPF app with .sdf database run on a computer without SQL Server installed

This question may seems a bit silly. The thing is I'm programming a WPF using VS2010, which contains a .sdf database (connection is ADO.NET).
Someone told me that if I use a SQL Server Express database it can be run on any PC even it has no SQL Server installed. But after I tried executing in my virtual machine (win7 & win xp), seems it cannot even start up.
So, can someone brief me, what database do people normally use in developing WPF software? Is it true that my program using a SQL Server database file cannot execute on PC without SQL Server installed?
Much appreciate in advance!
Yes, it can!
SQL Server Compact (that produces and uses .sdf) is the only SQL Server edition that does not require a server to be installed. All its code and logic is contained in the handful of DLL's that you need to include with your application. Just ship your app with those DLL's and you should be fine.
Read more about SQL Server Compact and how to use and deploy it on MSDN.
SQL Server Express (and any of the other editions, like Web, Standard, Developer, Enterprise) on the other hand does require an installation of the SQL Server Express edition - either on that machine, or somewhere in the network where your app runs (remote connections from the network are disabled by default, but can be enabled).

vs2008 loses connection to database after updates in ssms2008

here is my setup:
Sql server 2008 standard running on Vista - VMware running a XP machine with VS2008 inside it.
If I open a SQL database in my host computer in sql server management studio and make structure changes to the database and then go back to visual studio, my visual studio has lost connectin to the database (says a network error has occured) - refreshing does not work. Closing down VS and reopending fixes the problem.
Has anybody else noticed this or is there maybe something wrong in my setup I should be looking into?
I can query the database, add data, delete data with no issues - only if I change the structure such as relationships or add remove columns etc.
Thanks,
Joe
I don't know if your problem is the same as mine, but if it is you could probably fix it by resetting some settings in Visual Studio.
This might be a server faults question.
I had a similar issue with network sharing / SQL security in VMware (though mine was fusion on OS/X.) The issue seems to be the network drops and loses connections. In my case I was always able to resolve the issues with dhcp release / renew on the client.
I raised a support call with VMWare on it; the basic response was check your vmware is patched up-to-date and then make sure you have the right version of the vmware tools installed on the client. When that didn't work they had me change to full dhcp on the virtual machine and the host rather than fixed IP addresses.
I'd recommend NOT Attaching DB's as a file, but Attaching them to your local machine using SQL Server management studio express. You can use the following connectionstring:
connectionString="Data Source=(local)\sqlexpress;Initial Catalog=dbname;Integrated Security=SSPI;"
This will allow you to use the database from Visual Studio as well as in SQL Management studio....
edit the connectionstring is for SQL Express, you'd have to change it if you're running SQL Server 2008 (I believe change the Data Source to your machinename/ip)

Resources