JAVAでMySQLを使ってデータベースにアクセスしているのですが、INSERT文が作動しません。
データベース名はjojo0920_db、Netbeansです。
これを実行した後、もう一つのレコードを全件検索して表示するのを使ってもこれ以外のデータしか表示されませんでした。
import java.sql.*;
public class kadai2 {
public static void main(String args[]){
Connection db_con = null;
PreparedStatement db_st = null;
try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); db_con=DriverManager.getConnection("jdbc:mysql://localhost:3306/jojo0920_db","root",""); db_st=db_con.prepareStatement("INSERT INTO profiles(profilesID,name,tel,age,birthday)VALUES(6,'竜宮レナ','080-7859-3508',17,'1979-07-15')" ); db_st.close(); db_con.close(); }catch(SQLException e_sql){ System.out.println("接続時にエラーが発生しました:"+e_sql.toString()); }catch(Exception e){ System.out.println("接続時にエラーが起きました:"+e.toString()); }finally { if(db_con != null){ try{ db_con.close(); }catch(Exception e_con){ System.out.println(e_con.getMessage()); } } }
}
}
回答1件
あなたの回答
tips
プレビュー