Class.forName("oracle.JDBC.driver.OracleDriver").newInstance()
String url="JDBC:oracle:thin:@localhost:1521:orcl" //orcl为Oracle数据库的SID
String user="test"
String password="test"
Connection con=DriverManager.getConnection(url,user,password)
2)连接DB2数据库
Class.forName("com.ibm.db2.jcc.DB2Driver")
String url="JDBC:db2://localhost:5000/testDb"
String user="test"String password="test"
Connection con=DriverManager.getConnection(url,user,passwo
ADOConnection1.ConnectionString := 'DSN=MS Access DatabaseDBQ=mdb文件名DefaultDir=缺省工作路径DriverId=25FIL=MS AccessMaxBufferSize=2048PageTimeout=5PWD=密码UID=admin'例如:Access文件为db.mdb,设置密码为:hello,则:
ADOConnection1.ConnectionString := 'DSN=MS Access DatabaseDBQ=db.mdbDefaultDir=DriverId=25FIL=MS AccessMaxBufferSize=2048PageTimeout=5PWD=helloUID=admin'
无密码则为:
ADOConnection1.ConnectionString := 'DSN=MS Access DatabaseDBQ=db.mdbDefaultDir=DriverId=25FIL=MS AccessMaxBufferSize=2048PageTimeout=5PWD=UID=admin'
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)