-1

情報をmysqlに送信する簡単なコードがあります。

        Connection connection = null;
        Statement stmt;

        Properties connInfo = new Properties();
        connInfo.put("user", "Main");
        connInfo.put("password", "poiuyt");
        connection  = DriverManager.getConnection("jdbc:mysql://localhost/ABCNews", connInfo);


        String sql = "insert into abcnews_topics VALUES (null, '" + text_topic + "');";
        stmt = (Statement) connection.createStatement();
        stmt.executeUpdate(sql);

「text_topic」は私の情報を含む変数です。このコードは循環しており、各ステップで変数 (text_topic) の値が変化します。

そして、私の決定の代わりにプリペアド ステートメントを使用したいと考えています。どうやってするの?

4

2 に答える 2