JDTS Database Connectivity

I finally manage to connect my Java program to MS SQL Server 2000 using JDBC JDTS after 11 hours of understanding how to connect and configure things. I guess that’s the beauty of OpenSource tools you have to dedicate most of your time in learning things but I am pretty much sure after this painful learning curve things will get smooth.

Here is the Simple Code:

import java.sql.*;

public class NewApplication {

public static void main(String[] args){
Connection conn;
try{

Class.forName("net.sourceforge.jtds.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:jtds:sqlserver://ADVENT/DNS;user=mark;password=mark;namedPipe=true");
System.out.println("Successfully connected");
conn.close();
}
catch(Exception e){
System.err.println("Unable to connect");
e.printStackTrace();
System.exit(1);
}


}
}



Though I can search a lot of this code around the net most of it won't work. I've tried it. The one piece missing on their code is this:

namedPipe=true

Without it no matter how many times I tried to connect it will always refuse.

I used to hate curly braces but now things are getting better for me.

Comments

Anonymous said…
good! keep up the good work :D
maks said…
:D your welcome. mwah love you

Popular posts from this blog

Apple's Edge Over Microsoft?

High Grounds Cafe - Best Internet Cafe in the Philippines

John Gokongwei Speech before Ateneo 2004 Graduates