Re: Client "Host not found"
- From: Joe Weinstein <joeNOSPAM@xxxxxxx>
- Date: Tue, 14 Mar 2006 10:29:56 -0800
lujate wrote:
The ping command was ran from a command line, PING 'x.x.x.x'.
Here is the java code:
--------------------------------------------------------------------------------------------
import java.sql.*;
public class Jdbc {
public static void main (String args[]) throws Exception {
try {
java.lang.Class.forName
("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection c = java.sql.DriverManager.getConnection
("jdbc:sqlserver://x.x.x.x;user=Anonymous;password=guest;");
System.out.println("Connected");
}
catch (SQLException se) {
do {
System.out.println("SQL STATE: " + se.getSQLState());
System.out.println("ERROR CODE: " + se.getErrorCode());
System.out.println("MESSAGE: " + se.getMessage());
System.out.println();
se = se.getNextException();
} while (se != null);
se.printStackTrace();
}
}
}
--------------------------------------------------------------------------------------------
And the stack trace.
java.lang.NullPointerException
at java.lang.Throwable.<init>(Throwable.java:180)
at java.lang.Exception.<init>(Exception.java:29)
at java.lang.RuntimeException.<init>(RuntimeException.java:32)
at
java.lang.NullPointerException.<init>(NullPointerException.java:36)
at Jdbc.main(Jdbc.java:6)
Is ther something wrong with your JVM? What's
line 6 of your program? I don't even see where
an NPE could occur. Would you try this:
import java.sql.*;
import java.util.*;
public class Jdbc {
public static void main (String args[]) throws Exception {
try {
Properties props = new java.util.Properties();
props.put("user", "Anonymous");
props.put("password", "guest");
Driver d =
(Driver)
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
System.out.println("Instantiated driver");
Connection c = d.connect("jdbc:sqlserver://x.x.x.x", p);
System.out.println("Connected");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
.
- Follow-Ups:
- Re: Client "Host not found"
- From: lujate
- Re: Client "Host not found"
- References:
- Client "Host not found"
- From: lujate
- Re: Client "Host not found"
- From: Joe Weinstein
- Re: Client "Host not found"
- From: lujate
- Client "Host not found"
- Prev by Date: Re: Client "Host not found"
- Next by Date: Re: Client "Host not found"
- Previous by thread: Re: Client "Host not found"
- Next by thread: Re: Client "Host not found"
- Index(es):
Relevant Pages
|