Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
|
Java Databases Discussion specific to working with Java Databases. For other Java topics, please see related Java forums. For database discussions not specific to Java, please see the Database category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2004, 11:29 PM
Authorized User
 
Join Date: Feb 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to cash
Default SQL Server 2000 Driver for JDBC Errors

Hi,
 I try to use SQL Server 2000 Driver for JDBC, but also has mistake.
Please help me.

                                        thinks
import java.sql.*;
import javax.sql.*;

public class TestConnection
{
  public static void main(String args[])
  {
    Connection connection;
    Statement statement;
    ResultSet rs;
    String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver" ;
    String sourceURL = "jdbc:microsoft:sqlserver://192.168.0.73:1433";
    String username = "dmtzx";
    String password = "dmtzx";

    try
    {
      Class.forName(driver);
      connection = DriverManager.getConnection(sourceURL, username, password);
      statement = connection.createStatement();
      rs = statement.executeQuery("SELECT * FROM xdjy.xsxxb");

      while(rs.next())
      {
        System.out.println(rs.getString("id") + rs.getString("name"));
      }
      rs.close();
      statement.close();
      connection.close();
    }
    catch(SQLException se)
    {
      System.err.println("SQL Exception :" + se.getMessage());
    }
    catch(ClassNotFoundException ce)
    {
      System.err.println("Class Not Found Exception" + ce.getMessage());
    }
  }
}
SQL Exception :[Microsoft][SQL Server 2000 Driver for JDBC]Error establishing socket
 
Old March 31st, 2004, 08:09 AM
Authorized User
 
Join Date: Feb 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to cash
Default

I found the problem which in the code
the mistake is sql.
There are two ways to make the code work well.

One is modification the sourceURL
"jdbc:microsoft:sqlserver://192.168.0.73:1433;databasename=xdjy"

the other is modification the sql
"USE xdjy SELECT * FROM xsxxb"

 
Old December 22nd, 2006, 01:18 AM
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you can not see ms-sql-s in your 'netstat -a', this can be because
you are running a version of Microsoft SQL Server 2000 or
MSDE that has known security vulnerabilities
when used in conjunction with your version of Windows.
To reduce virus attacks, the TCP/IP and UDP network ports have been disabled.
To enable these ports, you must install a patch.
http://www.microsoft.com/sql/downloads/2000/sp4.mspx






Similar Threads
Thread Thread Starter Forum Replies Last Post
connect jdbc/odbc bridge to ms- sql server 2000 sushant2002 SQL Server 2000 0 July 3rd, 2007 08:28 PM
java.sql.SQLException: Error loading JDBC Driver jdphjp Java Databases 1 August 5th, 2004 12:46 AM
Cannot load JDBC driver class with com.mysql.jdbc. dzis Apache Tomcat 0 January 29th, 2004 11:57 AM
Cannot load JDBC driver class with com.mysql.jdbc. dzis MySQL 0 January 29th, 2004 11:31 AM
ODBC driver 2000.81.7713.00 for SQL 7.0 Jai SQL Server 2000 1 October 13th, 2003 11:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.