eclipse运行出现下列错误怎么办?
第一个类packageedu.dao;importjava.sql.Connection;importjava.sql.PreparedStatement;importj...
第一个类
package edu.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import edu.dumain.Users;
import edu.util.DBUtil;
public class UserDAO {
/**
* 1按手机号查询用户对象
*
* @param username
* 手机号
* @return 用户对象,如果手机号不存在,返回null
* @throws SQLException
*/
public Users findUserByName(String username) throws SQLException {
String sql = "select * from users where user_name = ?";
Connection conn = DBUtil.getConn();
PreparedStatement pstat = conn.prepareStatement(sql);
pstat.setString(1, username);
ResultSet rs = pstat.executeQuery();
if (rs.next()) {
Users user = new Users();
user.setUserName(rs.getString("USER_NAME"));
user.setUserPass(rs.getString("USER_PASS"));
user.setUserIsLogin(rs.getInt("USER_ISLOGIN"));
return user;
} else {
return null;
}
}
/**
* 2 保存新用户
*
* @param user
* user用户对象
* @throws SQLException
*/
public void saveUser(Users user) throws SQLException {
String sql = "INSERT INTO `users` (`USER_NAME`, `USER_PASS`, `user_islogin`) " + " VALUES (?, ?, ?) ";
Connection conn = DBUtil.getConn();
PreparedStatement pstat = conn.prepareStatement(sql);
pstat.setString(1, user.getUserName());
pstat.setString(2, user.getUserPass());
pstat.setInt(3, user.getUserIsLogin());
pstat.executeUpdate();
}
} 展开
package edu.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import edu.dumain.Users;
import edu.util.DBUtil;
public class UserDAO {
/**
* 1按手机号查询用户对象
*
* @param username
* 手机号
* @return 用户对象,如果手机号不存在,返回null
* @throws SQLException
*/
public Users findUserByName(String username) throws SQLException {
String sql = "select * from users where user_name = ?";
Connection conn = DBUtil.getConn();
PreparedStatement pstat = conn.prepareStatement(sql);
pstat.setString(1, username);
ResultSet rs = pstat.executeQuery();
if (rs.next()) {
Users user = new Users();
user.setUserName(rs.getString("USER_NAME"));
user.setUserPass(rs.getString("USER_PASS"));
user.setUserIsLogin(rs.getInt("USER_ISLOGIN"));
return user;
} else {
return null;
}
}
/**
* 2 保存新用户
*
* @param user
* user用户对象
* @throws SQLException
*/
public void saveUser(Users user) throws SQLException {
String sql = "INSERT INTO `users` (`USER_NAME`, `USER_PASS`, `user_islogin`) " + " VALUES (?, ?, ?) ";
Connection conn = DBUtil.getConn();
PreparedStatement pstat = conn.prepareStatement(sql);
pstat.setString(1, user.getUserName());
pstat.setString(2, user.getUserPass());
pstat.setInt(3, user.getUserIsLogin());
pstat.executeUpdate();
}
} 展开
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询