📄 notedaoimpl.java
字号:
package ly.impl ;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import ly.dao.noteDAO;
import ly.dbc.DBConnection;
import ly.vo.noteVO;
public class noteDAOImpl implements noteDAO
{
public void insert(noteVO note)
{
String sql = "INSERT INTO note(yhm,yhmm,dh,dz,yb,email) VALUES(?,?,?,?,?,?)" ;
PreparedStatement pstmt = null ;
DBConnection dbc = null ;
dbc = new DBConnection() ;
try
{
pstmt = dbc.getConnection().prepareStatement(sql) ;
pstmt.setString(1,note.getName()) ;
pstmt.setString(2,note.getPassword()) ;
pstmt.setString(3,note.getTel()) ;
pstmt.setString(4,note.getAddress()) ;
pstmt.setString(5,note.getYoubian()) ;
pstmt.setString(6,note.getEmail()) ;
pstmt.executeUpdate() ;
pstmt.close() ;
}
catch (Exception e)
{
System.out.println(e) ;
}
finally
{
dbc.close() ;
}
}
public noteVO queryAll(String status)
{
noteVO note = null ;
String sql = "select * from note where yhm=?" ;
PreparedStatement pstmt = null ;
DBConnection dbc = null ;
dbc = new DBConnection() ;
try
{
pstmt = dbc.getConnection().prepareStatement(sql) ;
pstmt.setString(1,status) ;
ResultSet rs = pstmt.executeQuery() ;
if(rs.next())
{
note = new noteVO() ;
note.setName(rs.getString(1)) ;
note.setPassword(rs.getString(2)) ;
note.setTel(rs.getString(3)) ;
note.setAddress(rs.getString(4)) ;
note.setYoubian(rs.getString(5)) ;
note.setEmail(rs.getString(6)) ;
}
rs.close() ;
pstmt.close() ;
}
catch (Exception e)
{
e.printStackTrace() ;
}
finally
{
dbc.close() ;
}
return note ;
}
public int queryMoney(String status)
{
String m = "a" ;
String n = "b" ;
int o = 0 ;
String sql = "select * from cunkuan where yhm=?" ;
PreparedStatement pstmt = null ;
DBConnection dbc = null ;
dbc = new DBConnection() ;
try
{
pstmt = dbc.getConnection().prepareStatement(sql) ;
pstmt.setString(1,status) ;
ResultSet rs = pstmt.executeQuery() ;
while(rs.next())
{
m = rs.getString(1) ;
n = rs.getString(2) ;
o = rs.getInt(3) ;
}
rs.close() ;
pstmt.close() ;
}
catch (Exception e)
{
e.printStackTrace() ;
}
finally
{
dbc.close() ;
}
return o ;
}
public void cunMoney(int money,String status)
{
String sql = "UPDATE cunkuan SET zhye=? WHERE yhm=?" ;
PreparedStatement pstmt = null ;
DBConnection dbc = null ;
dbc = new DBConnection() ;
try
{
pstmt = dbc.getConnection().prepareStatement(sql) ;
pstmt.setInt(1,money) ;
pstmt.setString(2,status) ;
pstmt.executeUpdate() ;
pstmt.close() ;
}
catch (Exception e)
{
System.out.println(e) ;
}
finally
{
dbc.close() ;
}
}
public void quMoney(int money,String status)
{
String sql = "UPDATE cunkuan SET zhye=? WHERE yhm=?" ;
PreparedStatement pstmt = null ;
DBConnection dbc = null ;
dbc = new DBConnection() ;
try
{
pstmt = dbc.getConnection().prepareStatement(sql) ;
pstmt.setInt(1,money) ;
pstmt.setString(2,status) ;
pstmt.executeUpdate() ;
pstmt.close() ;
}
catch (Exception e)
{
System.out.println(e) ;
}
finally
{
dbc.close() ;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -