2 Star 0 Fork 0

BESTI.IS.JAVA2018/20165318_sun_xiaoxuan

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
city.java 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
20165318 孙晓暄 提交于 7年前 . ch11 test
import java.sql.*;
public class city{
public static void main(String args[]) {
Connection con;
Statement sql;
ResultSet rs;
con = GetDBConnection.connectDB("world","root","sunxiaoxuan001");
if(con == null ) return;
String sqlStr =
"select * from city where Population>1016531";
try {
sql=con.createStatement();
rs = sql.executeQuery(sqlStr);
while(rs.next()) {
int ID=rs.getInt(1);
String Name=rs.getString(2);
String CountryCode=rs.getString(3);
String District=rs.getString(4);
long Population=rs.getLong(5);
System.out.printf("%d\t",ID);
System.out.printf("%s\t",Name);
System.out.printf("%s\t",CountryCode);
System.out.printf("%s\t",District);
System.out.printf("%d\n",Population);
}
con.close();
}
catch(SQLException e) {
System.out.println(e);
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/BESTI-IS-JAVA-2018/20165318_sun_xiaoxuan.git
git@gitee.com:BESTI-IS-JAVA-2018/20165318_sun_xiaoxuan.git
BESTI-IS-JAVA-2018
20165318_sun_xiaoxuan
20165318_sun_xiaoxuan
master

搜索帮助