今天做了什么:

完成了团队作业中需要使用的工具类

连接数据库的,将bitmap转化为base64和从base64转化为bitmap类型的工具类

package com.hui.testend.mytool;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;

import java.io.ByteArrayOutputStream;

public class ImageUtil {
public static String imageToBase64(Bitmap bitmap) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
byte[] buffer = byteArrayOutputStream.toByteArray();
String baseStr = Base64.encodeToString(buffer, Base64.DEFAULT);
return baseStr;
}

public static Bitmap base64ToImage(String bitmap64) {
byte[] bytes = Base64.decode(bitmap64, Base64.DEFAULT);
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
return bitmap;

}

}
package com.hui.testend.mytool;

import java.sql.*;

public class Util {
private static final String CLS="com.mysql.jdbc.Driver";
private static final String URl="jdbc:mysql://172.18.149.2:3307/light?characterEncoding=utf-8&useSSL=false";
//private static final String URl1="jdbc:mysql://172.18.149.174:3307/user1?characterEncoding=utf-8&useSSL=false";
private static final String USER="root";
private static final String PWD="1234";
public static Connection conn;
public static Statement stmt;
public static PreparedStatement pStmt;
public static ResultSet rs;
public static void getconn(){
try{
Class.forName(CLS);
conn=DriverManager.getConnection(URl,USER,PWD);
//System.out.println(conn+"99999999");
}catch (Exception e){
e.printStackTrace();
}
}
public static void close(){
try{
if (rs!=null){
rs.close();
rs=null;
}
if (stmt!=null){
stmt.close();
stmt=null;
}
if (pStmt!=null){
pStmt.close();
pStmt=null;
}
if (conn!=null){
conn.close();
conn=null;
}

}catch (Exception e){
e.printStackTrace();
}
}
}

 

遇到了什么困难:

在创建连接数据库的工具类时忘了添加联网权限

明天准备做什么:

继续完成团队作业

代码量  150行