odbc及oracle使用
Connection conn=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection( "jdbc:odbc:dbname","username", "userpassword");
mysql 使用
Connection conn=null;
Class.forName("org.gjt.mm.mysql.Driver");
Connection con = DriverManager.getConnection( "jdbc:mysql://hostip:3306/databasename?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull"
,"username","userpassword")
SQL2005使用
下載並安裝sqljdbc.jar ,classpath 一定要指定這個jar檔.
Connection conn=null;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection( "jdbc:sqlserver://192.168.5.11:1433;DatabaseName=dbname;", "username", "userpassword");
SQL2000使用
Class.forName"com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection m_Connection = DriverManager.getConnection "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=MyDatabase", "userid", "password");
沒有留言:
張貼留言