java 怎么用java連接sqlserver數(shù)據(jù)庫?
怎么用java連接sqlserver數(shù)據(jù)庫?使用jdbc odbc橋連接SQL server相對簡單。代碼如下:public void class{connection con statement s
怎么用java連接sqlserver數(shù)據(jù)庫?
使用jdbc odbc橋連接SQL server相對簡單。代碼如下:public void class{connection con statement st resultset RS int count try{Class.forname類(" sun.jdbc.odbc文件.jdbcodbcDriver“)con=driverManager(”jdbc:odbc數(shù)據(jù)庫名稱是數(shù)據(jù)庫登錄用戶名,pwd是登錄密碼=con.createStatement公司}catch(異常e){系統(tǒng)輸出打?。╡) }public ResultSet select(字符串sql){rs=圣excuteQuery(SQL)}//此方法用于在數(shù)據(jù)庫中查詢,其中添加try{}catch()public int update(string SQL){count}=st.excuteUpdate公司(sql)}//此方法用于在數(shù)據(jù)庫中進行添加、刪除和修改