mysql jdbc連線串 jdbc連線字串

2021-10-18 09:29:28 字數 969 閱讀 8046

mysql:

string driver="com.mysql.jdbc.driver"; //驅動程式

string url="jdbc:mysql://localhost:3306/db_name"; //連線的url,db_name為資料庫名

string username="username"; //使用者名稱

string password="password"; //密碼

class.forname(driver);

connection con=drivermanager.getconnection(url,username,password);

oracle:

string driver="oracle.jdbc.driver.oracledriver";  //連線資料庫的方法

string url="jdbc:oracle:thin:@localhost:1521:orcl";  //orcl為資料庫的sid

string username="username"; //使用者名稱

string password="password"; //密碼

class.forname(driver) ; //載入資料庫驅動

connection con=drivermanager.getconnection(url,username,password); //常用資料庫鏈結方式

db2:

//string driver="com.ibm.dbjdbc.net.dbdriver"; //連線不具有db2客戶端的provider例項

string url="jdbc:db2://localhost:5000/db_name"; //db_name為資料庫名

string username="username"; //使用者名稱

string password="password"; //密碼

class.forname(driver) ;

Mysql JDBC 連線串引數說明

jdbc mysql host port host port database 引數名1 引數值1 引數名2 引數值2 現只列舉幾個重要的引數,如下表所示 引數說明 預設值最低版本要求 user 資料庫使用者名稱 用於連線資料庫 所有版本 password 使用者密碼 用於連線資料庫 所有版本 us...

兩種資料來源連線的配置方式 jndi和jdbc

潤幹報表的資料來源配置是在reportconfig.xml中進行設定的,支援jndi資料來源配置和jdbc直連資料來源配置兩種。在讀取配置檔案的時候,會首先讀取jndi的配置,如果沒有相關的資料來源配置則會讀取jdbc直連配置的資料來源。1 jndi資料來源配置 即 在datasource中配置 此...

連線字串

建立資料庫連線 sqlconnection con new sqlconnection con.connectionstring system.configuration.configurationmanager.connectionstrings con tostring 配置檔案中已經配置好連線...