Bookmark Topic Watch Topic
  • New Topic active Connections issue...  RSS feed

Carmen Brianick
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi, this is a pretty lengthy question (sorry!) b/c I tried to put in as much detail about my problem as I can. I am totally new to JDBC and this server stuff, so please bear with me. I am getting this error:
at com.devx.tradingapp.model.Connect.getConnection(
at com.devx.tradingapp.model.Connect.displayDbProperties(
at com.devx.tradingapp.model.Connect.main(
Error Trace in getConnection() : [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
Error: No active Connection

1.) I've created a basic class called 'Connect' (code listed below) that connects to database using jdbc
2.) I have installed SQL Server 2000 (cd is from 2001)
3.)I downloaded Microsoft SQL Server 2000 Driver for JDBC sp3 ( I also tried sp2 but still doesn't work).
4.)I have tried tips listed on ";en-us;313178" but it still doesn't work.
However,the only thing I didn't perform on this page was to ping my server. I'm not really sure how to perform this b/c I don't know what my server name is. I'm currently running everything on my local computer. So do they mean 'ping localhost' or 'ping local'? Currently when I open SQL Server Enterprise Manager, this is the hierarchy that I have: Console Root > Microsoft SQL Servers > (local)(Windows NT) > Now there is the Databases, Security...etc folders.
5.) I run this java application on Eclipse: Run --> Run As --> Java Application. After I run this, I get error message listed above.
6.) My OS is Windows XP code is below. Any instructions, comments, or sample code is greatly appreciated!

Thanks so very much for your help!

***** Start *******
package com.devx.tradingapp.model;

import java.*;
public class Connect{
private java.sql.Connection con = null;
private final String url = "jdbc:microsoft:sqlserver://";
private final String serverName= "localhost";
private final String portNumber = "1433";
private final String databaseName= "Northwind";
private final String userName = "username";
private final String password = "password";
// Informs the driver to use server a side-cursor,
// which permits more than one active statement
// on a connection.
private final String selectMethod = "cursor";

// Constructor
public Connect(){}

private String getConnectionUrl(){
return url+serverName+":"+portNumber+";databaseName="+databaseName+";selectMethod="+selectMethod+";";

private java.sql.Connection getConnection(){
con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password);
if(con!=null) System.out.println("Connection Successful!");
}catch(Exception e){
System.out.println("Error Trace in getConnection() : " + e.getMessage());
return con;

Display the driver properties, database details

public void displayDbProperties(){
java.sql.DatabaseMetaData dm = null;
java.sql.ResultSet rs = null;
con= this.getConnection();
dm = con.getMetaData();
System.out.println("Driver Information");
System.out.println("\tDriver Name: "+ dm.getDriverName());
System.out.println("\tDriver Version: "+ dm.getDriverVersion ());
System.out.println("\nDatabase Information ");
System.out.println("\tDatabase Name: "+ dm.getDatabaseProductName());
System.out.println("\tDatabase Version: "+ dm.getDatabaseProductVersion());
System.out.println("Avalilable Catalogs ");
rs = dm.getCatalogs();
System.out.println("\tcatalog: "+ rs.getString(1));
rs = null;
}else System.out.println("Error: No active Connection");
}catch(Exception e){

private void closeConnection(){
}catch(Exception e){
public static void main(String[] args) throws Exception
Connect myDbTest = new Connect();

****** End *******
Bear Bibeault
Author and ninkuma
Posts: 66260
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!