import java.sql. *;
import java.util. *;
public class testJDBC {
public static void main (String [] args) throws Exception {
Class.forName ("com.sybase.jdbc3.jdbc.SybDriver"). newInstance ();
String url = "jdbc: sybase: Tds: 192.168.0.43:4100 / sql";
Properties sysProps = System.getProperties ();
sysProps.put ("user", "321321");
sysProps.put ("password", "123123");
Connection conn = DriverManager.getConnection (url, sysProps);
}
}
midterm connection that sentence has been given:
Exception in thread "main" java.sql.SQLException: JZ006: Caught IOException: java.net.ConnectException: Connection timed out: connect
at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError (Unknown Source)
at com.sybase.jdbc3.jdbc.ErrorMessage.raiseErrorCheckDead (Unknown Source)
at com.sybase.jdbc3.tds.Tds.a (Unknown Source)
at com.sybase.jdbc3.tds.Tds.a (Unknown Source)
at com.sybase.jdbc3.tds.Tds.login (Unknown Source)
at com.sybase.jdbc3.jdbc.SybConnection.a (Unknown Source)
at com.sybase.jdbc3.jdbc.SybConnection.handleHAFailover (Unknown Source)
at com.sybase.jdbc3.jdbc.SybConnection.
at com.sybase.jdbc3.jdbc.SybConnection.
at com.sybase.jdbc3.jdbc.SybDriver.connect (Unknown Source)
at java.sql.DriverManager.getConnection (Unknown Source)
at java.sql.DriverManager.getConnection (Unknown Source)
at testJDBC.main (testJDBC.java: 15)
I use sybase, to establish a database named sql.db, Position : G: \ sybase \ data \ sql.db, call 321 321 My account password is 123123 , and I directly open sybase, and then connect , enter the account password can be connected into this, but it Rom, ask me where I have a problem ?
------ Solution ---------------------------------------- ----
String url = "jdbc: sybase: Tds: 192.168.0.43:4100 / sql";
behind you do not specify a database name
this:
String url = "jdbc: sybase: Tds: 192.168.0.43:4100 / sql; databaseName = xxxx";
------ Solution -------- ------------------------------------
you use MyEclipse try, my teacher said , eclipse a problem , you need to connect to the database project , it is best to write in MyEclipse ah ,
------ For reference only -------------------- -------------------
Connection conn = DriverManager.getConnection (url, username, password);
------ For reference only ---------------------------------- -----
import java.sql. *;
import java.util. *;
public class testJDBC {
public static void main (String [] args) throws Exception {
Class.forName ("com.sybase.jdbc3.jdbc.SybDriver"). newInstance ();
String url = "jdbc: sybase: Tds: 192.168.0.168:5000 / sql; databaseName = sql";
Properties sysProps = System.getProperties ();
sysProps.put ("user", "123123");
sysProps.put ("password", "321321");
Connection conn = DriverManager.getConnection (url, sysProps);
}
}
into this , it's still useless, still had that error
------ For reference only --------------------- ------------------
brother, I have encountered such a problem Kazakhstan
egg pain die
------ For reference only ------------------------------ ---------
you see is not what you install sybase database , when, with the IP address : 127.0.0.1;
My question is this , url changed ip address 127.0.0.1 on the line
------ For reference only ---------------------------------- -----
encountered this problem today , version sybase12.5, you can log in directly using Sybase Central to create the database , no problems, but using myeclipse integrated connectivity , jdbc driver connection , jar used jconn2.jar , jconn3.jar not work, or incorrect connection is not on , doc environment , then sometimes directly ping ping fails, you are trying to solve , the problem of sharing first look to see which experts encountered such problems
没有评论:
发表评论