-1
有幾個關於我拼湊在一起的代碼的問題。加密純文本密碼並將變量傳遞給xml以顯示在android
首先,我如何加密密碼變量,以便它不以純文本格式存儲?
其次,我可以將'第一'&'最後'的變量傳遞給一個要顯示在android設備上的XML元素嗎?我如何才能最好地獲得要在Android屏幕上打印的「第一」,「最後」變量?
爲了清楚我沒有得到此代碼的工作,我只是想知道我可以如何使用android應用程序的輸出。
import java.sql.*;
public class SQL{
public static void main(String[] args) {
/*
Variables that store our login information and SQL driver information.
url = database url
dbName = name of table to query
driver = name of MySQL driver
userName = username for SQL server
password = password for SQL server
*/
String url = "jdbc:mysql://localhost:3306/";
String dbName = "testdb";
String driver = "com.mysql.jdbc.Driver";
String userName = "****";
String password = "****";
//Start our exception handling block.
try {
//Connect to the driver? I honestly have no idea what this does.
Class.forName(driver).newInstance();
//Establish a connection to the SQL server
Connection conn = DriverManager.getConnection(url+dbName,userName,password);
//Create a statement to be executed.
Statement stmt = conn.createStatement();
//The query that will be executed.
String sql = "SELECT * FROM Achievments";
//Create a results set variable that stores the output of our query.
ResultSet rs = stmt.executeQuery(sql);
//Start a while loop that executes while there are still results in the table?
while(rs.next()){
//Retrieve by column name
String first = rs.getString("ach_names");
String last = rs.getString("ach_text");
//Display values
System.out.print(first);
System.out.println(last);
}
rs.close();
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}
}
}