dポイントプレゼントキャンペーン実施中!

続き webアプリをつくってます。変数がなぜか渡りません。
見回ったのですが原因がわかりませんでした。
間違った箇所はどこですか。

package info.searchman;

import java.io.*;
import java.sql.*;
//import java.util.*;

public class ShinzinInfoTorokuBeans implements Serializable {


/**
*
*/
private static final long serialVersionUID = 1L;
private String Id;
private String name;
private String old;
private String taiju;
private String shintyo;
private String other;


//Constructor
public ShinzinInfoTorokuBeans() {
System.out.println("sitb constructor");
}

// Setter Methods
public void setId(String Id) {
this.Id = Id;
}

public void setName(String name) {
this.name = name;
}

public void setOld(String old) {
this.old = old;
}

public void setTaiju(String taiju) {
this.taiju = taiju;
}

public void setShintyo(String shintyo) {
this.shintyo = shintyo;
}

public void setOther(String other) {
this.other = other;
}



// Getting Methods

public String getId() {
return this.Id;
}

public String getName() {
return this.name;
}

public String getOld() {
return this.old;
}

public String getTaiju() {
return this.taiju;
}

public String getShintyo() {
return this.shintyo;
}

public String getOther() {
return this.other;
}

//execute insert
public void insert() {
try {
System.out.println("++++" +Id);
System.out.println("tib7 insert");


//JDBC Driver
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection("jdbc:postgresql:postgres","postgres","gokui");
Statement stmt = con.createStatement();
String table = "testweb";
String values = "(\'"+Id+"\', \'"+name+"\', \'"
+old+"\', \'"+taiju+"\', \'"+shintyo+"\', \'"+other+"\')";

//System.out.println("Id"+"name"+"old"+"taiju"+"shintyo+other");
String insertsql = "insert into "+table+" values " + values;
//sql
stmt.executeUpdate(insertsql);
//db close
stmt.close();
con.close();
} catch (Exception ex) {
System.out.println("Exception insertでエラー: " + ex.getMessage());

}
}
}
ここまで

A 回答 (2件)

Insertすべきパラメータが埋まらないって事かな?


であれば単純にShinzinInfoTorokuBeans#セッターを
呼び出しているところを見直したほうがよさそうだし、
セッターを呼び出しているところがすでに値を持っていなければ
それ以前の部分でって順を追ってみていくのがよだそうだね。
    • good
    • 0

> 変数がなぜか渡りません



どこからどこに渡らないの?
推測するにPostgreSQLのテーブルにInsertできない
ってことなんじゃないかと思うんだけど。
だとすると何かエラーが出てたりしない?
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!