1.用jdbc连接oracle的url怎么写import java.sql.* ;
public class wanglei
{
public static void main(String [] args)
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver") ;
// Driver oracle = new oracle.jdbc.driver.OracleDriver() ;
String url = "jdbc:oracle:thin:@192.168.1.9:1521:sky" ;
Connection c = DriverManager.getConnection(url,"wanglei","wanglei") ;
Statement stmt = c.createStatement() ;
String mends that users switch over to usingservice names.
格式三:Oracle JDBC Thin using a TNSName:
jdbc:oracle:thin:@<TNSName>
Example: jdbc:oracle:thin:@GL
Note:
Support for TNSNames was added in the driver release 10.2.0.1
常用的是前两种;另外其实还有oci的连接方式,一般用不上 。
3.db连接oracle数据库 connection URL 怎么写下面这些都是Oracle数据库连接字符串,总结的非常详细,但不是我总结的. ODBC新版本Driver={Microsoft ODBC for Oracle};Server=myServerAddress;Uid=myUsername;Pwd=myPassword;旧版本Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;OLE DB, OleDbConnection (.NET)标准连接,此连接字符串适用了微软的驱动 。
Provider=msdaora;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;受信连接Provider=msdaora;Data Source=MyOracleDB;Persist Security Info=False;Integrated Security=Yes;标准连接,由Oracle提供的驱动 。Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;受信连接Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;Oracle.DataAccess.Client.OracleConnectionData Source=TORCL;User Id=myUsername;Password=myPassword;标准安全连接Data Source=TORCL;Integrated Security=SSPI;使用ODP.NET而不使用tnsnames.oraData Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=http://www.xuexi88.com/zhishi/(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;OracleConnection, Oracle Data Provider, ODP.NET, System.Data.OracleClient.OracleConnection标准Data Source=MyOracleDB;Integrated Security=yes;用于8i RC3及以后的版本指定用户名和密码Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no;用于8i RC3及以后的版本忽略tnsnames.ora,另一种不需要使用DSN的连接方式 。
SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=http://www.xuexi88.com/zhishi/(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;使用上面的连接字符串可能会导致Visual Studio报告错误,如果您在使用中出现了这些问题,请使用下面的这种连接方式 。Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;使用连接池如果连接池服务程序找不到已经存在的连接池,它将根据连接字符串创建一个新的池,否则将循环使用池中已存在的连接 。
Data Source=myOracleDB;User Id=myUsername;Password=myPassword;Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;Incr Pool Size=5;Decr Pool Size=2;Windows身份验证Data Source=myOracleDB;User Id=/;特权连接使用SYSDBAData Source=myOracleDB;User Id=SYS;Password=SYS;DBA Privilege=SYSDBA;特权连接使用SYSOPERData Source=myOracleDB;User Id=SYS;Password=SYS;DBA Privilege=SYSOPER;复制密码过期处理过程当使用一个连接字符串连接数据库后,出现“密码已过期”的错误时,请执行OpenWithNewPassword命令来提供新密码 。Data Source=myOracleDB;User Id=myUsername;Password=myPassword;oConn.OpenWithNewPassword(sTheNewPassword);Proxy验证Data Source=myOracleDB;User Id=myUsername;Password=myPassword;Proxy User Id=pUserId;Proxy Password=pPassword;Core Labs OraDirect (.NET)User ID=myUsername;Password=myPassword;Host=ora;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;MS Data ShapeProvider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;User Id=myUsername;Password=myPassword; 。