????????Groovy????????
???????????? ???????[ 2014/9/22 10:53:19 ] ??????????????? ?????
???????????????????????
????1.???????
??????????????????SqlQuery
????<span style="font-family:'????'?? SimSun;font-size:16px;">import groovy.sql.*;<br><br>abstract class SqlQuery {<br><br> def sql;<br> def query;<br><br> def SqlQuery(sql??query){<br> this.sql=sql;<br> this.query=query;<br> }<br><br> def execute(){<br> def rowList=sql.rows(query);<br> def results=[];<br> def size=rowList.size();<br> 0.upto(size-1) { index-><br> results <<this.mapRow(rowList[index]);<br> }<br> return results;<br> }<br><br> def abstract mapRow(row);<br>}<br></span>
???????????Account??????????account??????
????<span style="font-family:'????'?? SimSun;font-size:16px;">class Account {<br><br> def id;<br> def name;<br> def url;<br><br> @Override<br> public String toString() {<br> return "|$id|$name|$url|";<br> }<br>}<br></span>
???????????AccountQuery????SqlQuery????????е??????rowMap
????<span style="font-family:'????'?? SimSun;font-size:16px;">import com.demo.db.SqlQuery;<br><br>class AccountQuery extends SqlQuery {<br><br> def AccountQuery(sql){<br> super(sql?? 'SELECT id?? name?? url FROM account');<br> }<br><br> @Override<br> public Object mapRow(Object row) {<br> //?????????<br> //def acc=new Account(id:row.getAt('id')??name:row.getAt('name')??url:row.getAt('url'));<br> //def acc=new Account(id:row.getAt(0)??name:row.getAt(1)??url:row.getAt(2));<br> def acc=new Account(<br> id:row.getProperty('id')??<br> name:row.getProperty('name')??<br> url:row.getProperty('url'));<br> return acc;<br> }<br>}<br></span>
????AccountQuery???????rowMap??????????÷??????????????????????????????Table - Object?????Ч????
???????????????е??????????????????????д????
????2.???SqlQuery???????account???????
????<span style="font-family:'????'?? SimSun;font-size:16px;">//??????????<br>def accountQuery=new AccountQuery(sql);<br>def accList=accountQuery.execute();<br>println 'Table <-> Object Query: ';<br>accList.each { acc-><br> println acc.toString();<br>}<br></span>
????accList????Account???????????鼯???????????????????????????????
????????Spring?????????????
????1.???????
????Spring???????MappingSqlQuery???????????AccountQuery??и?????????е?rowMap??????????????????????
????<span style="font-family:'????'?? SimSun;font-size:16px;">import com.demo.db.Account;<br><br>import org.springframework.jdbc.object.MappingSqlQuery<br><br>class AccountQuery extends MappingSqlQuery {<br><br> def AccountQuery(ds){<br> super(ds??'SELECT id?? name?? url FROM account');<br> this.compile();<br> }<br><br> @Override<br> protected Object mapRow(ResultSet rs?? int rowNumber) throws SQLException {<br> def acc=new Account(<br> id:rs.getInt('id')??<br> name:rs.getString('name')??<br> url:rs.getString('url'));<br> return acc;<br> }<br>}<br></span>
???????????????Spring??MappingSqlQuery??????????????????????DataSource?????????SQL???
???????????Account???DAO??AccountDAO????????????????????????????????????????y?????ó??????????????????????????????ɡ???????????????塣
????<span style="font-family:'????'?? SimSun;font-size:16px;">class AccountDao {<br><br> def ds;<br><br> def getAccounts(){<br> def aq=new AccountQuery(ds);<br> return aq.execute();<br> }<br>}<br></span>
????AccountDao?????getAccounts??????????÷??????????????account?????м???????AccountQuery??Mapping???????????????????
????2.???AccountDao??????????
????<span style="font-family:'????'?? SimSun;font-size:16px;">//????Spring<br>def ds=new DriverManagerDataSource(db.url?? db.user?? db.password);<br>def accountDao=new AccountDao(ds:ds);<br>accLists=accountDao.getAccounts();<br>println 'Spring MappingSqlObject Query: ';<br>accList.each { acc-><br> println acc.toString();<br>}<br></span>
????????Groovy????????????????Groovy??Java???????????????????????????????????API?????????PHP??????????????????Groovy??Java???????????????????
??????????
????????????????????????????????Groovy???????????Python??PHP??Nodejs?????????????е?Java????????????????????"Java?????????"???????????????????μ??????????????????????????????£?????????????·?????????????
??????????????SSH?? SSM??TSH??JSF???????Java??????????????????????????????????????????????????????????????????赸?????????????????ζ??????????????????????????????????????????????????????????????????
???????????Ч??????Ч???????????????????μ?Э?飬??????????????????????????????????????????????Щ???????????????????????????????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
?????????????????????????Щ????????????????????TC???????????????Щ???????????????????????????????????????????????(java .net ?????)???mysql???????????????????ж????д???Python???????????????(DB2)??????BufferPool????????????????????????????????6??????????????????滮???????????????-????????SQL Server???????????????????λ?????PHP??SQL????????????????????Pythonд???NoSQL????????? SQL ?е????????????? SQL ?е?????????Java???????:?????MySQL???????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????