public static void main(String[] args) 
{
/** give some ini number*/
int  count=1;
int  totalitem=0;
String user="sync4j";
         String passwd="sync4j";
         String url = "jdbc:microsoft:sqlserver://804-R/LQ:1433";
Connection con=null;
Statement stmt=null;
try {
         /**open the test database*/
            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
            System.out.println("Opening db connection");            con = DriverManager.getConnection(url,user,passwd);
            stmt = con.createStatement();
            
            }
        catch (ClassNotFoundException ex) {
            System.err.println("Cannot find the database driver classes.");
            System.err.println(ex);
                                          }
        catch (SQLException ex) 
        {
            System.err.println("Cannot connect to this database.");
            System.err.println(ex);
        }
对着做做,应该没问题的。