課程
/后端開發(fā)
/Java
/JDBC之 “ 對岸的女孩看過來”
這里類似于.net的參數(shù)化查詢嗎?
2018-05-04
源自:JDBC之 “ 對岸的女孩看過來” 2-4
正在回答
using?(SqlConnection con?=new?SqlConnection()){ con.ConnectionString?="************************"; con.Open(); SqlCommand cmd?=new?SqlCommand(); cmd.Connection?=?con; string?classId?="S201";
int age = 15; cmd.CommandText?="SELECT * FROM Student WHERE ClassId?= '"?+?classId?+?"' AND Age >" + age; //省略}
以上就是.net的,和JDBC是差不多的,都是連接數(shù)據(jù)庫,寫SQL,將值附給字段,然后進行數(shù)據(jù)庫操作等
舉報
一起領(lǐng)略JDBC的奧秘,為進一步學(xué)習(xí)集成框架打下良好的基礎(chǔ)
1 回答關(guān)于條件查詢的實現(xiàn)問題
1 回答添加數(shù)據(jù)在數(shù)據(jù)庫查詢時異常
1 回答關(guān)于數(shù)據(jù)類型
2 回答為什么我的Goddess類不能在Dao類里面實例化
1 回答查詢報錯,更新報錯但查詢沒問題
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2018-05-28
using?(SqlConnection con?=new?SqlConnection())
{
con.ConnectionString?="************************";
con.Open();
SqlCommand cmd?=new?SqlCommand();
cmd.Connection?=?con;
string?classId?="S201";
int age = 15;
cmd.CommandText?="SELECT * FROM Student WHERE ClassId?= '"?+?classId?+?"' AND Age >" + age;
//省略
}
以上就是.net的,和JDBC是差不多的,都是連接數(shù)據(jù)庫,寫SQL,將值附給字段,然后進行數(shù)據(jù)庫操作等