SQL Server 7 Connection - java

Hi, I am trying to connect to SQL sever 7 through java.
I have tried several examples located on the web, but am unsuccessful.
ANy help would be appreciated.
RockyFullenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kupra1Commented:
Whats your problem?
Paste your code here.
RockyFullenAuthor Commented:
I am trying to establish a connection to a SQL Server database using the jtds driver.
I have placed the jar file (jtds-1.1.jar) into my classpath (j2sdk1.4.2_04/bin).
When I execute the following code I get error "java.lang.ClassnotfoundException: net.sourceforge.jtds.jdbc.Driver"

[code]


  public static void main(String args []){

       // declare Connection and Statement objects
    Connection conn = null;
    String connstring = "jdbc:freetds:sqlserver://localhost/CF6CVDDeferment";
   
    try{
       
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        //conn = DriverManager.getConnection(connstring,"TPMCENTER", "TPMCENTER");
       
    }catch(Exception e){
    System.out.println(e);
    }
   
   
  }
[/code]

martie_11Commented:
that wont work, this is windows calss path,
one thing you can do is specify the path where the driver is when you compile  c:\pathOfDriver ->> path of you jar

javac -classpath c:\pathOfDriver -d \classes src\*.java
kupra1Commented:
hey RockyFullen,
  you should not put your jar file into the "bin" directory. Although you can put your jar file in any folder as long as that folder in the classpath, it is a good practice to put it in the lib directory.

Try to compile it like this:
I presume that you are Java class name is "Test.java".

From the command prompt, set the classpath first like this.
set classpath=%classpath%;path_of_the_folder_which_contains_the_jar_file;  

After setting this, compile and run. This will override any other classpath settings.
javac Test.java
java Test

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.