当前位置:网站首页>JDBC reads MySQL data list
JDBC reads MySQL data list
2022-06-27 07:21:00 【Qingyun ing】
import com.mysql.jdbc.Driver;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class JDBCDemo {
public static void main(String[] args) throws Exception {
//1 Get the connection
String url = "jdbc:mysql://IP:Port/db_name";
String username = "username ";
String password = "password ";
Connection conn = DriverManager.getConnection(url, username, password);
//2 sql sentence
String sql = "select * from account ";
//3 Access to perform sql The object of
Statement stmt = conn.createStatement();
//4 perform sql
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()){
System.out.println("-----------------");
System.out.println("ID:"+rs.getInt("id")+" Name:"+rs.getString("name")+" Age:"+rs.getInt("age"));
}
//6 Release resources
stmt.close();
conn.close();
}
}
边栏推荐
猜你喜欢

Redis cache penetration, cache breakdown, cache avalanche

Idea one click log generation

2022 le fichier CISP - Pte (i) contient:

Matlab GUI interface simulation DC motor and AC motor speed simulation

面试官:大量请求 Redis 不存在的数据,从而打倒数据库,你有什么方案?

聊聊领域驱动设计

Fractional Order PID control
![[openairinterface5g] rrcsetupcomplete for RRC NR resolution](/img/61/2136dc37b98260e09f3be9979492b1.jpg)
[openairinterface5g] rrcsetupcomplete for RRC NR resolution

内存屏障今生之Store Buffer, Invalid Queue

How to write controller layer code gracefully?
随机推荐
POI replacing text and pictures in docx
uview的安装和功能
[leetcode] day90 the element with the smallest K in the binary search tree
Interviewer: please introduce cache penetration, cache null value, cache avalanche and cache breakdown, which are easy to understand
OPPO面试整理,真正的八股文,狂虐面试官
JDBC读取Mysql数据列表
Tar: /usr/local: cannot find tar in the Archive: due to the previous error, it will exit in the last error state
Thesis reading skills
Idea one click log generation
From 5 seconds to 1 second, the system flies
面试官:大量请求 Redis 不存在的数据,从而打倒数据库,你有什么方案?
内存屏障今生之Store Buffer, Invalid Queue
OpenCV怎么下载?OpenCV下载后怎么配置?
使用 Blackbox Exporter 测试网络连通性
POI export excle
Restrictions on the use of tidb
vs怎么配置OpenCV?2022vs配置OpenCV详解(多图)
On gpu: historical development and structure
jupyter notebook文件目录
Centos7.9 install MySQL 5.7 and set startup