提交文件

This commit is contained in:
Your Name
2021-08-16 22:17:40 +08:00
commit 971c2e0e8a
26 changed files with 1270 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package util;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
public class APKVersionCodeUtils {
/**
* 获取版本号名称
*
* @param context 上下文
* @return
*/
public static String getVerName(Context context) {
String verName = "";
try {
verName = context.getPackageManager().
getPackageInfo(context.getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return verName;
}
}

View File

@@ -0,0 +1,46 @@
package util;
import java.sql.*;
public class MysqlDriver {
public static Connection getConnection() {
Connection connection = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/" + "emoji" + "?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false", "root", "root");
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
return connection;
}
public static void close(Connection connection) {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public static void close(PreparedStatement preparedStatement) {
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public static void close(ResultSet resultSet) {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}