| Author |
Client "Host not found"
|
|
| lujate 2006-03-14, 11:23 am |
| I am trying to use JDBC to access data on an MS SQL Server from an IBM
iSeries server (aka AS/400). I compiled and ran a sample Java
application from the iSeries, and received the following error:
SQL STATE: 08S01
ERROR CODE: 0
MESSAGE: host.domain: Host host.domain not found
The host.domain returned is our iSeries system, which is the client not
the server. I can ping the SQL Server, so I know that the TCP/IP
connection is good.
I have been unable to determine any cause for this problem.
| |
| Joe Weinstein 2006-03-14, 1:23 pm |
|
lujate wrote:
> I am trying to use JDBC to access data on an MS SQL Server from an IBM
> iSeries server (aka AS/400). I compiled and ran a sample Java
> application from the iSeries, and received the following error:
>
> SQL STATE: 08S01
> ERROR CODE: 0
> MESSAGE: host.domain: Host host.domain not found
>
> The host.domain returned is our iSeries system, which is the client not
> the server. I can ping the SQL Server, so I know that the TCP/IP
> connection is good.
>
> I have been unable to determine any cause for this problem.
Show us the URL you're using for the connection attempt and
the ping command you're using. I would try:
Properties props = new Properties();
Driver d = new com.microsoft.sqlserver.jdbc.SQLServerDriver();
props.put("user", "sa");
props.put("password", "secret");
String myDBMSMachineIPAddre
ss = "162.27.24.999"; // eg:
c = d.connect("jdbc:sqlserver://" + myDBMSMachineIPAddre
ss + ":1433", props );
Joe Weinstein at BEA Systems
| |
| lujate 2006-03-14, 1:23 pm |
| 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;pas
sword=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> (NullPointerExceptio
n.java:36)
at Jdbc.main(Jdbc.java:6)
| |
| Joe Weinstein 2006-03-14, 1:23 pm |
|
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;pas
sword=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> (NullPointerExceptio
n.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();
}
}
}
>
| |
| lujate 2006-03-14, 1:23 pm |
| I tried your code and here's the output:
Instantiated driver
com.microsoft.sqlserver.jdbc.SQLServerException: host.domain: Host
host.domain not found
at java.lang.Throwable.<init>(Throwable.java:195)
at java.lang.Exception.<init>(Exception.java:41)
at java.sql.SQLException.<init>(SQLException.java:40)
at
com.microsoft.sqlserver.jdbc.SQLServerException.<init>(Unknown Source)
at
com.microsoft.sqlserver.jdbc.SQLServerException. makeFromDriverError(
Unknown
Source)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection. build70Logon(Unknown
Source)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown
Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown
Source)
at Jdbc.main(Jdbc.java:6)
| |
| Joe Weinstein 2006-03-14, 8:23 pm |
| lujate wrote:
> I tried your code and here's the output:
>
> Instantiated driver
>
> com.microsoft.sqlserver.jdbc.SQLServerException: host.domain: Host
> host.domain not found
> at java.lang.Throwable.<init>(Throwable.java:195)
There's definitely something funny going on with
your JVM and/or network config, but ping worked...
Hmmmmm. Try this program, to see if Java can open
a socket to the DBMS like a driver would:
import java.io.*;
import java.net.*;
public class isAnythingListeningO
n
{
public static void main(String argv[])
throws Exception
{
if (argv.length != 2)
{
System.out.println("Usage: isAnythingListeningO
n <host> <port>");
System.out.println("eg:\n% java isAnythingListeningO
n myDBMSMachine 1433");
System.exit(0);
}
try
{
System.out.println("\nTrying to open a socket with host "
+ argv[0] + " and port " + argv[1] + " ...");
Socket socket = new Socket(argv[0],(new Integer(argv[1]).intValue()));
System.out.println("\nYes, there is, we got a socket.");
socket.close();
}
catch (Exception e)
{
System.out.println("We failed to open a socket. Here's why:\n");
e.printStackTrace();
System.out.println("\n(Either there is no machine named '" + argv[0]
+ "' or\nnothing is listening there on port "
+ argv[1] +")\n");
}
}
}
Joe Weinstein at BEA Systems
>
> at java.lang.Exception.<init>(Exception.java:41)
>
> at java.sql.SQLException.<init>(SQLException.java:40)
>
> at
> com.microsoft.sqlserver.jdbc.SQLServerException.<init>(Unknown Source)
>
> at
> com.microsoft.sqlserver.jdbc.SQLServerException. makeFromDriverError(
Unknown
> Source)
> at
> com.microsoft.sqlserver.jdbc.SQLServerConnection. build70Logon(Unknown
> Source)
> at
> com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source)
>
> at
> com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown
> Source)
> at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown
> Source)
> at Jdbc.main(Jdbc.java:6)
>
| |
| lujate 2006-03-14, 8:23 pm |
| "Yes, there is, we got a socket."
| |
| Joe Weinstein 2006-03-14, 8:23 pm |
|
lujate wrote:
> "Yes, there is, we got a socket."
Ok, I'm stumped. I hope the MS folks can chip in.
Joe
| |
| lujate 2006-03-14, 8:23 pm |
| Thank you for all your help.
| |
| lujate 2006-03-16, 11:23 am |
| We did not have any DNS servers defined on our iSeries. I did not
think that would cause any problems because I was referencing the SQL
Server via IP address. I added the DNS servers and that fixed the
problem.
Thanks
|
|
|
|