当前位置:网站首页>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(); } }}

边栏推荐
- [nrf51][nrf52] nrfconnect installation instructions guide
- High performance current limiter guava ratelimiter
- Data statistical analysis (SPSS) [7]
- 多机局域网办公神器 rustdesk 使用强推!!!
- leetcode - 295. Median data flow
- Tech Cloud Report: Mixed Office B side: How Safety and Efficiency can be combined?
- What is the dry goods microservice architecture? What are the advantages and disadvantages?
- Adelaidet (detectron2) & abcnet environment configuration
- Wi-Fi 7 来啦,它到底有多强?
- leetcode - 295. 数据流的中位数
猜你喜欢

科班出身,结果外包都不要

Yangzhou needs one English IT Helpdesk Engineer -20220216

The efficiency of 20 idea divine plug-ins has been increased by 30 times, and it is necessary to write code

数据库和缓存如何保持一致性

干货丨微服务架构是什么?有哪些优点和不足?

【滤波器设计】根据设计指标使用matlab定制滤波器

【布里渊现象】光纤布里渊温度和应变分布同时测量系统研究

【FPGA数学公式】使用FPGA实现常用数学公式

Common methods of JS date and time

【FPGA+sin】基于DDS(直接数字合成)的正弦信号发生器模块FPGA实现
随机推荐
访问数据库时出现错误
源代码防泄露技术种类浅析
Black screen and error reporting when loading custom models for gazebo with roslaunch
不使用union实现Mysql 列转行
Implementation of b+ tree index based on xlsx
基于可变参模板实现的线程池
二叉树序列化与反序列化(leetcode(困难))
[Brillouin phenomenon] Study on simultaneous measurement system of Brillouin temperature and strain distribution in optical fiber
树莓派用VNC Viewer方式远程连接
MobileOne: 移动端仅需1ms的高性能骨干
Baidu AI Cloud service grid product CSM release 𞓜 hot public beta
Nuxt - 每个页面单独设置 SEO 相关标签及网页标题、图标等(页面配置 head)
Technology cloud report: side B of mixed office: how to have both security and efficiency?
Kingbase export table structure
Django model generates docx database design documents
[nrf51][nrf52] nrfconnect installation instructions guide
选对学校,专科也能进华为~早知道就好了
New listing of operation light 3.0 -- a sincere work of self subversion across the times
人大金仓(KingBase)导出表结构
Data collection and management [2]