1 Star 0 Fork 0

20175308/java_programming_20175308

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
Example11_3.java 1.13 KB
Copy Edit Raw Blame History
20175308 authored 2019-04-27 15:20 +08:00 . 提交第十一章代码
import java.sql.*;
public class Example11_3 {
public static void main(String[] args) {
Connection con;
Statement sql;
ResultSet rs;
con = GetDBConnection.connectDB("Fomalhaut", "root", "*************");
if (con == null)
return;
String c1 = " year(birthday)<=2000 and month(birthday)>7";
String c2 = " name Like '张_%'";
String c3 = " height>1.65";
String sqlStr = "select*from mess where" + c1 + " and" + c2 + " and" + c3 + "order by birthday";
try {
sql = con.createStatement();
rs = sql.executeQuery(sqlStr);
while (rs.next()) {
String number = rs.getString(1);
String name = rs.getString(2);
Date date = rs.getDate(3);
float height = rs.getFloat(4);
System.out.printf("%s\t", number);
System.out.printf("%s\t", name);
System.out.printf("%s\t", date);
System.out.printf("%.2f\n", height);
}
} catch (SQLException e) {
System.out.println(e);
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/hpc-beiluoshimen/java_programming_20175308.git
git@gitee.com:hpc-beiluoshimen/java_programming_20175308.git
hpc-beiluoshimen
java_programming_20175308
java_programming_20175308
master

Search