PearlJamFanatic
asked on
having trouble with sybase connection string
I have the following information.
Sybase 12.5
Username: abcdefgh
Password: abcd1234
ini:
[SYB_ABCDEV]
master=NLWNSCK,oakabcd02.h ld.us.abc- intl.com,4 000
query=NLWNSCK,oakabcd02.hl d.us.abc-i ntl.com,40 00
What should be the connection string for the above.
Sybase 12.5
Username: abcdefgh
Password: abcd1234
ini:
[SYB_ABCDEV]
master=NLWNSCK,oakabcd02.h
query=NLWNSCK,oakabcd02.hl
What should be the connection string for the above.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
jdbc:sybase:Tds:<host>:<po rt>/<datab ase>
pass the username and password in the call or include in the properties
pass the username and password in the call or include in the properties
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I get error
JZ003: Incorrect URL format. URL: oakabcd02.hld.us.abc-intl. com:4000:
JZ003: Incorrect URL format. URL: oakabcd02.hld.us.abc-intl.
ASKER
i am using
dbUrl="jdbc:sybase:Tds:" + host +
":" + port + ":" + "?SERVICENAME=" + dbName;
dbUrl="jdbc:sybase:Tds:" + host +
":" + port + ":" + "?SERVICENAME=" + dbName;
You don't need servicenmae just slash and then dbnmae
ASKER
for yan : I am still getting the same error.
That's what they all show - try slash after the port and then immediately database name
Post your code
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I i were to login to this databse using ASE isql then
I have the following in the Sybase ASE logon screen
Login: abc
Password:xyz
Database:dbone
Server: abcdefgh
charset:
Hostname: <My machine name>
I have the following in the Sybase ASE logon screen
Login: abc
Password:xyz
Database:dbone
Server: abcdefgh
charset:
Hostname: <My machine name>
try this:
jdbc:sybase:Tds:<My machine name>:2048/dbone
jdbc:sybase:Tds:<My machine name>:2048/dbone
Did you try this fromat:
Connection conn =
DriverManager.getConnectio
(assuming you put the host name for <My machine name>)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One more simple example from
http://www.sybase.com/detail?id=1009790
The following sample code illustrates how to invoke the jConnect driver, make a connection, issue a SQL statement, and process results.
import java.io.*;
import java.sql.*;
public class SampleCode
{
public static void main(String args[])
{
try
{
/*
* Open the connection. May throw a SQLException.
*/
Connection con = DriverManager.getConnection(
"jdbc:sybase:Tds:myserver:3767", "sa", "");
/*
* Create a statement object, the container for the SQL
* statement. May throw a SQLException.
*/
Statement stmt = con.createStatement();
/*
* Create a result set object by executing the query.
* May throw a SQLException.
*/
ResultSet rs = stmt.executeQuery("Select 1");
/*
* Process the result set.
*/
if (rs.next())
{
int value = rs.getInt(1);
System.out.println("Fetched value " + value);
}
}
/*
* Exception handling.
*/
catch (SQLException sqe)
{
System.out.println("Unexpected exception : " +
sqe.toString() + ", sqlstate = " +
sqe.getSQLState());
System.exit(1);
}
System.exit(0);
}
}
ASKER
new error message
Could not connect to database:
java.sql.SQLException: JZ006: Caught IOException: java.net.UnknownHostExcept ion: abcdefgh
Could not connect to database:
java.sql.SQLException: JZ006: Caught IOException: java.net.UnknownHostExcept
ASKER
for_yan: where is the Databse name in your code sample?
This is better as URL format is OK.
Probably try host still as your real host name
Probably try host still as your real host name
> jdbc:sybase:Tds:<My machine name>:2048/dbone
you need to put your machine name (ie. the host that the database is running on) in place of <My machine name>
you need to put your machine name (ie. the host that the database is running on) in place of <My machine name>
and check what port your database is listening on (I've included the default)
That is good question.
I think still in all other places thety indicate slash/databasename after host name
Perhaps in thios case they have some default ofr that
But try slash/database nmae - di you try it?
I think still in all other places thety indicate slash/databasename after host name
Perhaps in thios case they have some default ofr that
But try slash/database nmae - di you try it?
But it looks that ports may be diffeent
But you seem to know that it is 4000
But you seem to know that it is 4000
ASKER
the database server is defanately not hosted on my machine. there is some mistake in the ISE sybase logon screen
Did you try systematically all the variants?
Your ini file should probably have correct hostname and port,
at least worth a try. Is there any place from ehrre you get this "dbone" name?
Did you try all variants of code?You showed only with "SERVICENAME",
but in the examples they have slashes in most cases
Your ini file should probably have correct hostname and port,
at least worth a try. Is there any place from ehrre you get this "dbone" name?
Did you try all variants of code?You showed only with "SERVICENAME",
but in the examples they have slashes in most cases
ASKER
This is what i have in the ini files of the client
[SYB_CRDDEV]
master=NLWNSCK,oakautonomy 02.hld.uk. fid-intl.c om,4000
query=NLWNSCK,oakautonomy0 2.hld.uk.f id-intl.co m,4000
I am able to connect and run queries using ISE.
[SYB_CRDDEV]
master=NLWNSCK,oakautonomy
query=NLWNSCK,oakautonomy0
I am able to connect and run queries using ISE.
ASKER
can the moderator please edit my earlier post it needs to sensitised.
So try this:
Connection conn =
DriverManager.getConnectio
or the same with port 2048
try this and let me know error
jdbc:sybase:Tds:oakautonom y02.hld.uk .fid-intl. com/dbone
and also:
jdbc:sybase:Tds:oakautonom y02.hld.uk .fid-intl. com:4000/d bone
jdbc:sybase:Tds:oakautonom
and also:
jdbc:sybase:Tds:oakautonom
Connection conn =
DriverManager.getConnectio
or the same with port 2048
It looks like port numbers with Sybase are all over the place:
5000, 5010,7100, 2048,3367
And for several numbers they say those are default
And maybe 4000 is specicifc for that protocol NLNWSCK,
so mybe with jdbc it could be different.
Try without and try several of the port numbers
5000, 5010,7100, 2048,3367
And for several numbers they say those are default
And maybe 4000 is specicifc for that protocol NLNWSCK,
so mybe with jdbc it could be different.
Try without and try several of the port numbers
this is from:
http://www.razorsql.com/docs/help_sybase.html
about Sybase port numbers:
Sybase Adaptive Server Enterprise JDBC Driver
DRIVER CLASS: com.sybase.jdbc2.jdbc.SybD river (use jdbc3 for newer versions)
CLASS LOCATION: The Sybase installation usually includes the jConnect product. The jConnect directory structure usually contains a classes directory that houses the jconn2.jar file. This jar file can usually be used for the class location when connecting to Sybase. You may also be able to download jConnect directly from Sybase as a separate download. Consult your Sybase documentation for more information.
JDBC URL FORMAT: jdbc:sybase:Tds:<host>:<po rt>
There is generally no default port for Sybase, although port 7100 is used by some JDBC drivers as the default port to connect to if no port is specified for sybase. Also, port 5000 seems to sometimes be referred to as the default port for Sybase. Usually, if the default port is being used by the database server, the :<port> value of the JDBC url can be omitted.
Examples:
jdbc:sybase:Tds:neptune.ac me.com:710 0
jdbc:sybase:Tds:127.0.0.1: 7100
http://www.razorsql.com/docs/help_sybase.html
about Sybase port numbers:
Sybase Adaptive Server Enterprise JDBC Driver
DRIVER CLASS: com.sybase.jdbc2.jdbc.SybD
CLASS LOCATION: The Sybase installation usually includes the jConnect product. The jConnect directory structure usually contains a classes directory that houses the jconn2.jar file. This jar file can usually be used for the class location when connecting to Sybase. You may also be able to download jConnect directly from Sybase as a separate download. Consult your Sybase documentation for more information.
JDBC URL FORMAT: jdbc:sybase:Tds:<host>:<po
There is generally no default port for Sybase, although port 7100 is used by some JDBC drivers as the default port to connect to if no port is specified for sybase. Also, port 5000 seems to sometimes be referred to as the default port for Sybase. Usually, if the default port is being used by the database server, the :<port> value of the JDBC url can be omitted.
Examples:
jdbc:sybase:Tds:neptune.ac
jdbc:sybase:Tds:127.0.0.1:
Make sure you can ping oakabcd02.hld.us.abc-intl. com first. If you can't, the chances are (though not conclusive) that you won't be able to connect to it. Let me know what happens
ping oakabcd02.hld.us.abc-intl.com
You can follow that up with telnet. If you don't know the port, then you need to find out. Guesswork will simply waste your time, there being tens of thousands to choose from. If you can't connect with telnet, then you almost certainly won't with your Java code, and the former is faster to check.
telnet oakabcd02.hld.us.abc-intl.com 4000
ASKER
This worked. I was using the wrong jar. Can you beat that?
dbUrl="jdbc:sybase:Tds:" + host +
":" + port+"/"+dbName;
dbUrl="jdbc:sybase:Tds:" + host +
":" + port+"/"+dbName;
com.sybase.jdbc2.jdbc.SybD
jconn2.jar
http://www.redmountainsw.com/wordpress/archives/jdbc-connection-urls
Perhaps this should work:
DriverManager.getConnectio