Opening SQL Server Express via JDBC in Mathematica? - jdbc

I have two computers with two (ostensibly) identical installations of SQL Server Express 2008 R2, both running Windows 7 64-bit. On one computer (call it "red"), I can execute the following mathematica code to open a connection to the database and read data
Needs["DatabaseLink`"]
conn = OpenSQLConnection[
JDBC[
"Microsoft SQL Server(jTDS)",
"localhost"],
"Instance" -> "SQLExpress"]
I have the jTDS driver for sql server installed in c:\windows\system32\ntlmauth.dll. I copied the dll from the working machine "red" to the non-working machine "black."
I used the SQL-Server import and export tool to transfer a very simple database from "red" to "black" and verified that the database is accessible by running LinqPad on "black" and reading data. All good.
Now, I try to run the Mathematica code above on "black" and I get an undiagnosable error message, namely:
JDBC::error: "!(TraditionalForm`\"Network error IOException: Connection refused: connect\") "
I just know this is going to be one of those nightmarish permission issues with the localservice account or the network-service account. I do not have Sql-Server Management Studio on machine "black" and I was unable to find the appropriate version of SSMS to install for SQL Server 2008 R2 Express (the SSMS Express 2008 version does not install, citing "known compatibility issues.") I don't really miss SSMS since LinqPad works fine for my development tasks.
I do not know how to diagnose or workaround or proceed in any way -- I'm completely blocked and would be very grateful for advice or guidance.

Somewhat guessing here, but I'd try
conn = OpenSQLConnection[
JDBC[
"Microsoft SQL Server(jTDS)",
"localhost:1433;instance=SQLExpress"]]
I'm pretty sure OpenSQLConnection[] doesn't take an "Instance" option. It might work if passed like this:
conn = OpenSQLConnection[
JDBC[
"Microsoft SQL Server(jTDS)",
"localhost:1433"], "Properties"->{"instance"->"SQLExpress"}]

Connection Error while connecting to SQL Server. It is not an authentication error.
It is just that may be your SQL Server is not configured to accept request through
through the transport protocol that you are using. Open SQL Server Surface Configuration
Manager and allow to accept connection from all ways provided.

Related

SQL Server 2017 Connections working in ASP.NET C# Web projects, but not in Windows projects, in Visual Studio 2019

Using the basic SqlConnection code below, I have discovered that, at my workstation, I am unable to connect to our Sql Server 2017 deployment via ASP.NET C# code in any given type of Windows-based project, such as Winforms (.NET Framework or Core) or Console apps. However, this code will run without incident in any Web-based project, such as Web Forms or MVC, either using .NET Framework or Core.
protected void testConnection()
{
string con = "Server=MySqlServer;database=MyDatabase;Integrated Security=true";
using (SqlConnection cnn = new SqlConnection(con))
{
cnn.Open();
cnn.Close();
}
}
In a web project, this code runs. In a Windows project, I get this error:
System.Data.SqlClient.SqlException: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'
In investigating this problem, I have tried the following:
Explicitly declaring the domain on which my SQL server is found (eg. MySqlServer.domain.com). No good.
Explicitly declaring the SQL Server port number, according to the example shown on connectionstrings.com (eg. MySqlServer, 1433). We do use the standard port number, for the record. No good.
Changing the protection level of the test method (protected/private/public). No good.
Connecting to the SQL Server in PowerShell. This connection worked.
Pinging in the SQL Server in a command prompt. The server responded in 1ms consistently.
I have asked other users on this network to test this code in a Winforms project on their workstations. No one is able to reproduce my issue.
Consulted my sysadmin. He is so far not able to find any reason why I should be having this issue.
The only difference I have noticed in all of this is that, when I declare the port number, the Inner Exception returned with the error reads "Win32Exception: A non-recoverable error occurred during a database lookup". Otherwise, it simply reads "Access is Denied."
All of this tells me that the issue is obviously something peculiar to my workstation, but I have no idea what, apart from some firewall or other local security setting that the sysadmin neglected to check. Has anyone encountered this problem?
My VS 2019 installation is only one revision out of date as of this writing, 16.8.3 as opposed to 16.8.4. I am able to connect to and run TSQL code on any database I care to via SSMS. We connect using Windows Authentication. According to the results of "select ##version", our version of SQL Server is 2017, 14.0.3356.20 (x64).
Any insight is appreciated.
We fixed it by forcing Named Pipes to be enabled in SQL Server, as opposed to using the default setting.

How to connect sql developer to Oracle database using instant client_12_1

I have downloaded the oracle instant client 12_1 but i'm unable to connect to the oracle database.when i tried using sql developer it is displaying the following error.
The Network could not be established.
I'm using windows 7 and my Oracle_home path is defautly set in the system variables as
path
E:\app\dell\product\11.2.0\dbhome\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
I suspect you've begun the headache of messing with the connection string. I seriously recommend you find the option in SQL Developer that will allow you to connect directly to the server (bypass TNSNAMES) and use EZ Connect. The connection string will look like this:
server.whatevz.com:port/sidname
I don't use SQL Developer, so I can't point to it specifically, but I have used it and configured it as such, and it works fine. I'm a fan of PL/SQL Developer (All Around Automation) myself.

SQL Server 2008 R2 Installation Error "Trust Relationship Failed"?

When I install SQL Server 2008 R2, the Database Engine Services feature don't install due to the error "The Trust Relationship between the primary domain and the trusted domain failed."
For context, I'm trying to get into ASP.NET MVC3 and when I try to add/browse a database in Visual Studio 2010, I get errors saying that it can't connect to the SQL Express database, Error 40. When I run the SQL Server Configuration Manager, and select the SQL Server Services, I get "The remote procedure call failed [0x800706be]"
I did some research, regarding this error 40; I've tried, to run Server Configuration Manager as a Administrator, change the TCP/IP settings in Client Protocols to Enabled, and it still didn't work. I uninstalled SQL Server 2008 R2 and reinstalled it and found that the Database Engine Services and SQL Server Replication failed to install, with the error message "The Trust Relationship between the primary domain and the trusted domain failed."
Any ideas?
Delete EVERYTHING.
This is dedicated to anyone who thought like me and thought you could get rid of one or two things, and reinstall. Anything with SQL Server, delete it. Make that Add/Remove Programs as clean as possible before reinstalling the server.
Also, be sure to have administrative rights/run as Admin turned on. Otherwise you may have a SQLEXPRESS server running, but you can't access it (or because of my work computer) delete it due to a user rights issue that goes beyond the scope of Stack Overflow. :)
In that case, you should be able to install a new instance (I.E. SQLEXPRESS1). Just be sure to check your data connection strings. :)

IIS to SQL Server Error 26, Same connection string works outside of IIS but not from within

I have gone through every checklist I could find for configuring SQL Server I could find. I get the same issue on Windows Server 2008 and Windows 7 Pro. First the environment:
SQL Server Express 2012 --installed as main instance (i.e. no named instances)
IP access turned on
Firewall exception for SQLServer
SQL Server user for application access
Windows Server 2008 service pack 2 (also tested with Windows 7 service pack 1)
IIS 7 (also tested with 7.5 with the same results)
.NET 4.0
Our own database code integrated in a .NET MVC 3 application
We have a tool we developed to import data from the old Ruby on Rails app into the new ASP.NET MVC 3 app. The tool can connect to the database using the user account we created, and that's how I discovered some permissions issues for access to stored procedures. This is the tool we are using to verify the connection works.
Data Source=SERVER_IP,1433;Network Library=DBMSSOCN;Database=MYDB;User ID=webuser;Password=webpassword;multipleactiveresultsets=true;
We are using a straight IP address, but to protect our infrastructure I substituted the IP, username, and password. But this is the structure of the connection string we are using. Following the checklists, I was able to connect from another machine on our network using the import tool to the database and import data. I was also able to import data from the same machine that IIS is installed on.
The same connection string provides the dreaded Error 26 "can't find the database server" message on both Windows Server 2008 and Windows 7 Pro:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I have exhausted every resource I can find, and can't seem to get any closer to an answer. I'm not trying to mount file based database, IIS has read/write access to the web application in any case.
I've ruled out the firewall as a cause for the issue. I've tried the settings with the firewall on and completely turned off. There has to be some other permissions level problem that's happening. Problem is I have no idea what permissions level things I have to check.
After opening a ticket with Microsoft, it turns out I was my own worst enemy. The model classes were set up in their own DLL so I could use them for data migration and other supporting tools for the website.
The DLL was looking in the assembly config for the connection string, and if it wasn't found it would use a reasonable default. Problem is the web application never overrode the location from the Web.config file.
The application couldn't find it because I didn't install the database with the default settings.

.NET application times out or does not connect when invoking a stored procedure accesses Oracle linked server

This .NET application used to work. When it did we were using the Oracle ODBC 9i. We moved to 10 g did not work anymore. Now at 11g stills does not work. I have set SQL Command Timeouts all over the place. I have set the connection timeout and the query timeout in the linked server properties to 120. I can run the proc from SQL Server Management studio and it works. It just does not work within my .NEt application anymore. Should I create a second connection string( to linked server) in the .NET app? We are at SQL Server 2005. Any Ideas??
Has your server you're connecting to moved, or are there now firewalls in place between the two servers?
I would check connectivity between the two first.
Try connecting to the oracle server using telnet on port 1521.
Alternatively, try using ODAC and checking your tnsnames.ora is configured correctly.
(It depends what provider you're using though.)

Resources