发布网友 发布时间:2022-05-02 08:32
共2个回答
懂视网 时间:2022-05-02 12:53
package Util; 2 3 import java.io.FileInputStream; 4 import java.io.FileNotFoundException; 5 import java.io.IOException; 6 import java.sql.Connection; 7 import java.sql.DriverManager; 8 import java.sql.PreparedStatement; 9 import java.sql.ResultSet; 10 import java.sql.SQLException; 11 import java.sql.Timestamp; 12 import java.util.Properties; 13 14 public class JdbcUtil { 15 16 static Properties pros=null; 17 static Connection con=null; 18 static ResultSet rs=null; 19 static PreparedStatement psSQL=null; 20 21 static { 22 pros =new Properties(); 23 try { 24 pros.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("db.properties")); 25 } catch (IOException e) { 26 e.printStackTrace(); 27 } 28 } 29 30 private JdbcUtil() { 31 32 } 33 34 public static Connection getMySQLConnection() { 35 try { 36 Class.forName(pros.getProperty("conPackage")); 37 con=DriverManager.getConnection(pros.getProperty("url"),pros.getProperty("user"),pros.getProperty("pwd")); 38 return con; 39 } catch (SQLException e) { 40 e.printStackTrace(); 41 return null; 42 }catch (ClassNotFoundException e) { 43 e.printStackTrace(); 44 return null; 45 } 46 } 47 48 public static boolean insertuser(String phone,String pwd ){ 49 try { 50 psSQL=con.prepareStatement("SELECT * FROM USER WHERE PHONE = ?"); 51 psSQL.setObject(1, phone); 52 rs=psSQL.executeQuery(); 53 if(rs.next()) { 54 return false; 55 }else { 56 psSQL=con.prepareStatement("INSERT INTO USER (PHONE,PWD) VALUE (?,?)"); 57 psSQL.setString(1, phone); 58 psSQL.setString(2, pwd); 59 psSQL.execute(); 60 return true; 61 } 62 } catch (SQLException e) { 63 e.printStackTrace(); 64 return false; 65 } 66 } 67 68 69 public static boolean register(String phone ,String pwd) { 70 try { 71 PreparedStatement psSQL =con.prepareStatement("SELECT * FROM USER WHERE PHONE = ? AND PWD= ?"); 72 psSQL.setString(1, phone); 73 psSQL.setString(2, pwd); 74 rs=psSQL.executeQuery(); 75 if(rs.next()) { 76 return true; 77 }else { 78 return false; 79 } 80 } catch (SQLException e) { 81 e.printStackTrace(); 82 return false; 83 } 84 } 85 86 public static boolean updateDetail(String phone,String nickname,String number,char sex,String name,String path) { 87 try { 88 psSQL =con.prepareStatement("UPDATE USER SET NICKNAME=? ,NUMBER =? ,SEX= ?, NAME=? ,PATH=? WHERE PHONE =?"); 89 psSQL.setString(1, nickname); 90 psSQL.setString(2, number); 91 byte intsex; 92 if(sex==‘男‘) { 93 intsex=1; 94 }else { 95 intsex=0; 96 } 97 psSQL.setObject(3, intsex); 98 psSQL.setString(4, name); 99 psSQL.setString(5, path); 100 psSQL.setString(6, phone); 101 psSQL.execute(); 102 return true; 103 } catch (SQLException e) { 104 e.printStackTrace(); 105 return false; 106 } 107 } 108 109 public static boolean addIcon(String phone,String imagePath) { 110 try { 111 psSQL=con.prepareStatement("update user set icon=? where phone=?"); 112 psSQL.setBlob(1, new FileInputStream(imagePath)); 113 psSQL.setString(2, phone); 114 psSQL.execute(); 115 return true; 116 } catch (FileNotFoundException e) { 117 e.printStackTrace(); 118 return false; 119 } catch (SQLException e) { 120 e.printStackTrace(); 121 return false; 122 } 123 } 124 125 public static boolean addDeal(String phone ,long time,String address,String goClass,String why,String teacher) { 126 try { 127 psSQL =con.prepareStatement("INSERT INTO DAIKE (PHONE,TIME,ADDRESS,CLASS,WHY,TEACHER) VALUE (?,?,?,?,?,?)"); 128 psSQL.setString(1, phone); 129 Timestamp timeStamp=new Timestamp(time); 130 psSQL.setTimestamp(2, timeStamp); 131 psSQL.setString(3,address); 132 psSQL.setString(4, goClass); 133 psSQL.setString(5, why); 134 psSQL.setString(6, teacher); 135 psSQL.execute(); 136 return true; 137 } catch (SQLException e) { 138 e.printStackTrace(); 139 return false; 140 } 141 } 142 143 public static ResultSet getDealList(String phone) { 144 try { 145 psSQL=con.prepareStatement("select * from daike where phone =?"); 146 psSQL.setString(1, phone); 147 return psSQL.executeQuery(); 148 } catch (SQLException e) { 149 e.printStackTrace(); 150 return null; 151 } 152 } 153 154 public static void close() { 155 try { 156 if(rs!=null) { 157 rs.close(); 158 } 159 } catch (SQLException e) { 160 e.printStackTrace(); 161 } 162 try { 163 if(psSQL!=null) { 164 psSQL.close(); 165 } 166 } catch (SQLException e) { 167 e.printStackTrace(); 168 } 169 try { 170 if(con!=null) { 171 con.close(); 172 } 173 } catch (SQLException e) { 174 e.printStackTrace(); 175 } 176 } 177 178 179 } JdbcUtil1 url:jdbc:mysql://localhost:3306/didi?useUnicode=true&characterEncoding=utf-8&useSSL=false 2 user:root 3 pwd:123456 4 conPackage:com.mysql.jdbc.Driver 5 userTable:userdb.properties
dididaikeJdbcUtil备份
标签:phone private cti ade ext exce ddr src nic
热心网友 时间:2022-05-02 10:01
Absente与Didi D 的区别在哪里
Absente也是GM非常火爆的一款,杨幂、唐嫣、林心如都有爆照,框形没有Lovesome那么圆 ,但又没有Dreamer那么Man,属于男女通吃的中性款,杨洋、李敏镐 、李光洙等男明星也有爆照,镜片形状与Didi D更接近,但是Absente的鼻托是凸出来的,镜框整体立体感更强,而且镜腿是金属与板材结合,板材部分的颜色与镜框相同,(例如:镜框是橘色,镜腿后半截,耳挂部分也是橘色板材)这点设计者真是别出心裁!注:Absente和Absente one 的形状一样,区别在于后者是金属鼻托,镜片的宽度和高度比前者小2mm。