提交文件
This commit is contained in:
28
src/main/java/util/APKVersionCodeUtils.java
Normal file
28
src/main/java/util/APKVersionCodeUtils.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
46
src/main/java/util/MysqlDriver.java
Normal file
46
src/main/java/util/MysqlDriver.java
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user