jtextfieldにDBの値を表示し、DBの値を修正・更新したいです。
すでにGUIの方はSwingに作成しています。
DBの仕様は以下になります。
テーブルカラム名
id,idname,syorinenndo1,syorinenn4,syoriseireki14の合計10列あります。
上記の順番で、フィールド値は以下になります。
1001,大阪,1,2,3,4,2000,2001,2002,2003
while文の中身(DBの値を表示・修正・更新するためのコード)がわからないです。
参考URLでも構いませんので、ご教授お願いします。
Windows10
jdk15.0
mySQLserver 5.7
mySQL Workbench8.0
Java
1import java.sql.Connection; 2import java.sql.DriverManager; 3import java.sql.PreparedStatement; 4import java.sql.ResultSet; 5import java.sql.SQLException; 6 7public class Mmm { 8 public static void main(String[] args) { 9 try{ 10 Class.forName("com.mysql.cj.jdbc.Driver"); 11 Connection conn = DriverManager.getConnection( 12 "jdbc:mysql://127.0.01:3306/new_","root","psw"); 13 14 String sql ="select id,idname from tetuduki;"; 15 PreparedStatement st = conn.prepareStatement(sql); 16 System.out.println("MySQLに接続できました!"); 17 ResultSet rs =st.executeQuery(sql); 18 19 while(rs.next()) { 20 21 22 } 23 st.close(); 24 rs.close(); 25 26 }catch(ClassNotFoundException e) { 27 System.out.println("SQLExeception:" + e.getMessage()); 28 }catch(SQLException e) { 29 System.out.println("SQLExeception:" + e.getMessage()); 30 } 31 } 32 33}