当前位置:网站首页>Error accessing database
Error accessing database
2022-06-29 04:05:00 【CSDN Q & A】
package db;
import java.sql.*;
public class Test {
public static void main(String[] args) {
Connection cn;
PreparedStatement psm=null;
ResultSet rs; //ResultSet Interface is used to temporarily stage the result set queried from the database
DBCon dbcon=new DBCon();
cn=dbcon.getConnection(); // Get database objects
Classes classes=new Classes();
String sql="select * from classes";
try {
psm=cn.prepareStatement(sql);
rs=psm.executeQuery();
if(rs.next()) { // Judge whether the result is found
rs.absolute(0);
while(rs.next()) {
String classNum=rs.getString(2);
String className=rs.getString(3);
String classSex=rs.getString(4);
String classTime=rs.getString(5);
String classAcademy=rs.getString(6);
String classSpecialized=rs.getString(7);
String classClassa=rs.getString(8);
classes.setNum(classNum);
classes.setName(className);
classes.setSex(classSex);
classes.setTime(classTime);
classes.setAcademy(classAcademy);
classes.setSpecialized(classSpecialized);
classes.setClassa(classClassa);
System.out.println(classes.getNum()+","+classes.getName()+","+classes.getSex()+","+classes.getTime()+","+classes.getAcademy()+","+classes.getSpecialized()+","+classes.getClassa());
}
} } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}

边栏推荐
- I came from a major, so I didn't want to outsource
- SQL 数据记录如何上下行合并
- c语言 --- 分支结构
- New listing of operation light 3.0 -- a sincere work of self subversion across the times
- The second meeting of the Second Council of Euler open source community was held, and Xinhua III, hyperfusion and Godson Zhongke became members of the Council
- Data collection and management [1]
- Live broadcast preview | neurips special session I & Young Scientists special session
- Ling Jing thinks about her own way
- 干货丨微服务架构是什么?有哪些优点和不足?
- yolox出现 RuntimeError: DataLoader worker (pid(s) 17724, 1364, 18928) exited unexpectedly
猜你喜欢

不使用union实现Mysql 列转行

Seura 2 test code summary

基于xlsx的B+树索引实现

I came from a major, so I didn't want to outsource

Why are you a test / development programmer? Can you recall

Cloud native weekly | grafana 9 was officially released; The Chinese version of cloud native vocabulary is now online

How to merge upstream and downstream SQL data records

Efficientnetv2 - get smaller models and faster training with NAS, scaling, and fused mbconv

访问数据库时出现错误

Wi-Fi 7 来啦,它到底有多强?
随机推荐
大神们 在富函数的open中从mysql连接池里取连接 连接池初始化是20个 如果富函数的并行度是1
Logstash starts too slowly or even gets stuck
《运营之光3.0》全新上市——跨越时代,自我颠覆的诚意之作
【C语言】详解线程回收函数 pthread_join
Data collection and management [4]
中小型企业网络的组建
If you choose the right school, you can enter Huawei as a junior college. I wish I had known
Data collection and management [12]
Yangzhou needs one English IT Helpdesk Engineer -20220216
[laravel series 8] out of the world of laravel
Wi-Fi 7 来啦,它到底有多强?
moudo网络库剖析
Data statistical analysis (SPSS) [4]
What is the dry goods microservice architecture? What are the advantages and disadvantages?
Is the sink usually the JDBC insert update delete?
Share 60 divine vs Code plug-ins
【C语言】开启一个线程
自己动手搭建一个简单的网站
智能视觉组比赛流程草案
开发者方案 · 环境监测设备(小熊派物联网开发板)接入涂鸦IoT开发平台