Visit Our UNIX and Linux User Community


Unix to Sql Server via JDBC


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix to Sql Server via JDBC
# 1  
Old 02-18-2008
Unix to Sql Server via JDBC

I am trying to connect SQL SERVER VIA JDCB. Following is something I tried and will appreciate any help what I am doing wrong
Here's what I did, I tried several variations, but I keep getting this error:

Code:
Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect.  Invalid URL

I tried:

Code:
Driver d = (Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();

Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://133.5.144.155/:1433/IE;selectMethod=cursor", "jdbc123", "test1456"); replacing ://133.5.144.155 with \\IP

my classpath is :
voyager->whseuser: echo $CLASSPATH

/apps/twhse/scripts/jen:/apps/twhse/scripts/jen/mssqlserver/lib/msutil.jar:/apps/twhse/scripts/jen/mssqlserver/lib/mssqlserver.jar:/apps/twhse/scripts/jen/mssqlserver/lib/msbase.jar
and it's not giving me a classpath error, so I think my classpath is right.

import java.sql.*;

//import oracle.jdbc.*;
public class HelloWorldApp {

    public static void main(String[] args) throws Exception {

       System.out.println("Hello World!"); // Display the string.

Driver d = (Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();

Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://133.5.144.155/:1433/IE;selectMeth

od=cursor", "jdbc123", "test456");
    }
}

I have never tried this on a sqlserver before, only in oracle.
will appreciate any response at
thanks
sam
# 2  
Old 02-19-2008
Quote:
will appreciate any response at xxx@xxx.com
Please read the rules before posting, in this particular case, rule 10
Quote:
(10) Don't post your email address and ask for an email reply. Don't send a private message with a technical question. The forums are for the benefit of all, so all Q&A should take place in the forums.
The exact format of the URL will depend on what you are using to connect but the format I know for talking to SQL server instances is:
jdbc:<client>:mssqlserver4:<instancename>@<ip/dns>:<port>
Munging the data in your supplied URL would produce:
jdbc:microsoft:sqlserver:IE@133.5.144.155:1433

You'd probably do better looking at your client config manual for the exact config file syntax to use.

Previous Thread | Next Thread
Test Your Knowledge in Computers #690
Difficulty: Medium
The Aircraft Navigation Computer Heathkit OC-1401/OCW-1401 used nine-level RPN in 1978.
True or False?

9 More Discussions You Might Find Interesting

1. IP Networking

Connection to DB from client server through jdbc:Oracle:Oci8 fail

We tried to use to connect to DB using jdbc:Oracle:Oci8:@<SERVICE-A>. Connection fail / refuse with one DB .But its working with other databases. But through toad, jdbc thin client were able to connect. But this has happen suddenly and were able to connect previously. How to navigate this... (0 Replies)
Discussion started by: udara
0 Replies

2. Shell Programming and Scripting

Invoking sql server from UNIX

I would like to invoke a procedure in SQL server which will return some results of a select query from UNIX script. I would like to invoke this procedure and load the data into a flat file in UNIX. Can you please help? I am not able to find any sample programs in Internet. (1 Reply)
Discussion started by: madhu.sushmitha
1 Replies

3. Shell Programming and Scripting

Unix and SQL server

Hi All, I am accessing Unix through putty (i.e. unix is installed on other server and i am accessing it remotely through putty). I am having SQL Server 2008 installed on my computer. Now i want to access sql server via. unix. Could some one please help me in this!!! Thanks (2 Replies)
Discussion started by: preetpalkapoor
2 Replies

4. Emergency UNIX and Linux Support

How to connect Unix and Sql Server 2005?

Hi All Can any one please help me about How to connect Unix with Sql Server 2005 I want to do it urgently and i didn't find the way. (14 Replies)
Discussion started by: parthmittal2007
14 Replies

5. Shell Programming and Scripting

Unix with sql Server 2005

Hello All I am getting a problem.What i want to do is to connect unix(korn shell) and sql server 2005. But it is not happening. The task is to schedule a job using crown or something else that connect with sql server 2005 and run the query and save the result in a text file. (5 Replies)
Discussion started by: parthmittal2007
5 Replies

6. Programming

JDBC code to pass the SQL query as parameter and execute?

Below i have the sample code. i need to pass the entire query from file or as parameter and read the results and write into a output file. here the number of columns are unknown. some times it may be 2,3 or entire columns from the table. read all the column results and write into a comma... (0 Replies)
Discussion started by: laknar
0 Replies

7. Shell Programming and Scripting

From Solaris UNIX to MS SQL Server

Hello, my problem is, that I want to send an SQL-Statement via ksh-Shell to an MS-SQL-Database based on SQL Server 2005. I want to receive a file, which can be used for further actions on UNIX (Sun OS 5.9). ODBCUnix and JDBC and FreeTDS are not allowed. Does anybody have a suggestion? Br,... (0 Replies)
Discussion started by: usagi67
0 Replies

8. UNIX for Dummies Questions & Answers

MS SQL Server on UNIX

Hi GURUs, I have following queries: 1) If its possible to configure Microsoft SQL Server database on a UNIX machine, if yes, can any body pls point me to the guide to acheive the same. 2) I know Oracle runs perfectly on UNIX based machines, can any body point me to the guide to achieve the... (6 Replies)
Discussion started by: patras
6 Replies

9. UNIX for Dummies Questions & Answers

Installing Ms Sql Server 2000 On Unix

Hello As per requirements, can i Install a MSSQL SERVER on UNIX , is it possible., can i install or not.., could u plz give me reply with some installation details.......... Regards&Thanking You sreedhar G (1 Reply)
Discussion started by: sreedhargunda
1 Replies

Featured Tech Videos