2022-11-03
一、base標簽
1、作用:用于添加web專案的前綴,
2、放置位置:放置在head標簽內部,一般放在首行,
3、使用方式:<base href="https://www.cnblogs.com/專案名稱/">,在html網頁中的其他(例如:圖片,超鏈接...)使用下相對路徑的前面將“./”去掉,因為它是指的是base 之后的路徑,使用的就是絕對路徑,注意前“/”后“/”,一定要加,
因為要大量替換相對路徑到絕對路徑,因此有一個快捷方式,使用“Ctrl+R”進行批量替換,
二、加密方式
常使用的加密方式:訊息摘要(例如:有MD5)
三、JDBC
1、JDBC的含義:
JDBC是java程式連接各種資料庫的API,它是由一組公共的介面和各個資料庫提供的驅動類構成,
2022-11-04
四、將java中添加的資料增加到資料庫中
1、首先先要確定是在哪個資料庫中添加,之后找到是在哪個表中添加,
2、使用的實體:
1 Scanner input = new Scanner(System.in); 2 System.out.println("請輸入姓名:"); 3 String ename = input.next(); 4 5 System.out.println("請輸入薪資:"); 6 double salary = input.nextDouble(); 7 8 System.out.println("請輸入出生日期:"); 9 String birthday = input.next(); 10 11 System.out.println("請輸入性別:"); 12 String gender = input.next(); 13 14 System.out.println("請輸入手機號碼:"); 15 String tel = input.next(); 16 17 18 System.out.println("請輸入郵箱:"); 19 String email = input.next(); 20 21 22 input.close(); 23 24 String url = "jdbc:mysql://localhost:3306/資料庫?serverTimezone=UTC"; 25 Connection conn = DriverManager.getConnection(url, "資料庫的用戶名", "資料庫的連接密碼"); 26 27 String sql = "INSERT INTO t_employee(ename,salary,birthday,gender,tel,email,hiredate) VALUES(?,?,?,?,?,?,?)"; 28 PreparedStatement pst = conn.prepareStatement(sql); 29 30 pst.setObject(1,ename); 31 pst.setObject(2,salary); 32 pst.setObject(3,birthday); 33 pst.setObject(4,gender); 34 pst.setObject(5,tel); 35 pst.setObject(6,email); 36 pst.setObject(7,new Date()); 37 38 int len = pst.executeUpdate(); 39 System.out.println(len>0?"添加成功":"添加失敗"); 40 pst.close(); 41 conn.close();
說明:第27行是執行的sql陳述句,后面添加的內容可以先用?來占位,第30-36行表示7個問號代表的具體的內容,
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/527771.html
標籤:Java
下一篇:Leetcode刷題第二周
