JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java 新手區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 如何修改(error:Parameter index out of range)
huangbb12345





發文: 19
積分: 0
於 2014-02-06 23:50 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的程式碼如下所示,
我想把test.txt檔裡的資料存進資料庫裡
txt檔的部分內容如下:
1001, <1,88069>, 287
10017, <1,88069>, 136
1002, <1,88069>, 98
1003, <1,88069>, 387
10033, <87070,88069>,1
10036, <87070,88069>,1
1004, <1,88069>, 1102
分別想把第一欄位存成資料庫中的item,第二欄位存成lifetime,第三欄位存成count,
但我執行程式時,跑出下面的error,請問要如何修改呢?
謝謝各位的幫忙!!
InsertDB Exception :java.sql.SQLException: Parameter index out of range (0 < 1 ).
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
  at db.jdbcmysql2.main(jdbcmysql2.java:185)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package db;
 
import java.io.File;
import java.io.IOException;
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.PreparedStatement; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.sql.Statement; 
import java.util.Scanner;
 
public class jdbcmysql2
{ 
  private Connection con = null; //Database objects 
  //連接object 
  private Statement stat = null; 
  //執行,傳入之sql為完整字串 
  private ResultSet rs = null; 
  //結果集 
  private PreparedStatement pst = null; 
  //執行,傳入之sql為預儲之字申,需要傳入變數之位置 
  //先利用?來做標示 
  
  private String dropdbSQL = "DROP TABLE udp2 "; 
  
  private String createdbSQL = "CREATE TABLE udp2 ("+"item VARCHAR(15)"+",lifetime VARCHAR(255)"+",count INTEGER)"; 
  
  private String insertdbSQL = "insert into udp2(item,lifetime,count) VALUES(?,?,?) from udp2 "; 
  
  private String selectSQL = "select * from udp2 "; 
  
  public jdbcmysql2() 
  { 
    try 
    { 
      Class.forName("com.mysql.jdbc.Driver"); 
      //註冊driver 
      con = DriverManager.getConnection( 
          "jdbc:mysql://localhost/udp?useUnicode=true&characterEncoding=Big5","root","test"); 
      //取得connection
 
      //jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5
      //localhost是主機名,test是database名
      //useUnicode=true&characterEncoding=Big5使用的編碼 
      
    } 
    catch(ClassNotFoundException e) 
    { 
      System.out.println("DriverClassNotFound :"+e.toString()); 
    }//有可能會產生sqlexception 
    catch(SQLException x) 
    { 
      System.out.println("Exception :"+x.toString()); 
    } 
    
  } 
  //建立table的方式 
  //可以看看Statement的使用方式 
  public void createTable() 
  { 
    try 
    { 
      stat = con.createStatement(); 
      stat.executeUpdate(createdbSQL); 
    } 
    catch(SQLException e) 
    { 
      System.out.println("CreateDB Exception :" + e.toString()); 
    } 
    finally 
    { 
      Close(); 
    } 
  } 
  //新增資料 
  //可以看看PrepareStatement的使用方式 
  public void insertTable(String item, String lifetime, String count) 
  { 
    try 
    { 
      pst = con.prepareStatement(insertdbSQL); 
      
      pst.setString(0, item); 
      pst.setString(1, lifetime); 
      pst.setString(2, count); 
      pst.executeUpdate(); 
    } 
    catch(SQLException e) 
    { 
      System.out.println("InsertDB Exception :" + e.toString()); 
    } 
    finally 
    { 
      Close(); 
    } 
  } 
  //刪除Table, 
  //跟建立table很像 
  public void dropTable() 
  { 
    try 
    { 
      stat = con.createStatement(); 
      stat.executeUpdate(dropdbSQL); 
    } 
    catch(SQLException e) 
    { 
      System.out.println("DropDB Exception :" + e.toString()); 
    } 
    finally 
    { 
      Close(); 
    } 
  } 
  //查詢資料 
  //可以看看回傳結果集及取得資料方式 
  public void SelectTable() 
  { 
    try 
    { 
      stat = con.createStatement(); 
      rs = stat.executeQuery(selectSQL); 
      System.out.println("Item\t\tLifetime\t\tCount"); 
      while(rs.next()) 
      { 
        System.out.println(rs.getInt("item")+"\t\t"+ 
            rs.getString("lifetime")+"\t\t"+ rs.getString("count")); 
      } 
    } 
    catch(SQLException e) 
    { 
      System.out.println("DropDB Exception :" + e.toString()); 
    } 
    finally 
    { 
      Close(); 
    } 
  } 
  //完整使用完資料庫後,記得要關閉所有Object 
  //否則在等待Timeout時,可能會有Connection poor的狀況 
  private void Close() 
  { 
    try 
    { 
      if(rs!=null) 
      { 
        rs.close(); 
        rs = null; 
      } 
      if(stat!=null) 
      { 
        stat.close(); 
        stat = null; 
      } 
      if(pst!=null) 
      { 
        pst.close(); 
        pst = null; 
      } 
    } 
    catch(SQLException e) 
    { 
      System.out.println("Close Exception :" + e.toString()); 
    } 
  } 
  
 
  public static void main(String[] args) throws IOException 
  { 
    //測看看是否正常 
    jdbcmysql2 test = new jdbcmysql2(); 
    test.dropTable(); 
    test.createTable(); 
    
    Scanner scan = new Scanner(new File("test.txt"));
    while (scan.hasNext())
    {
      String perLine = scan.nextLine().trim();
      String[] dataAry = perLine.split(", ");
      test.insertTable(dataAry[0], dataAry[1], dataAry[2]); 
      test.SelectTable();
        
    }  
  } 
}


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
jimwayne





發文: 220
積分: 0
於 2014-02-07 09:52 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
InsertDB Exception :java.sql.SQLException: Parameter index out of range (0 < 1 ).
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at db.jdbcmysql2.main(jdbcmysql2.java:185)


錯誤訊息解讀~
錯誤發生在 jdbcmysql2.java 的第 185 行
錯誤原因是因為 java.lang.ArrayIndexOutOfBoundsException,也就是指定的索引不合法
不合法的原因是 Parameter index out of range (0 < 1 ),即索引最小的允許值是 1,但程式給了 0。


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
lasaka





發文: 32
積分: 0
於 2014-02-07 10:29 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
10033, <87070,88069>,1
10036, <87070,88069>,1

逗點後面少了空格= =


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:lasaka]
huangbb12345





發文: 19
積分: 0
於 2014-02-07 11:36 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
對耶 謝謝你!
但我修改完後錯誤依然存在
InsertDB Exception :java.sql.SQLException: Parameter index out of range (0 < 1 ).

我知道錯誤訊息是告訴我185行有問題
但是陣列不是都是從0開始嗎@@?
我不知道應該修改哪邊才對... Sad


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
lasaka





發文: 32
積分: 0
於 2014-02-07 11:45 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
就是..取陣列的時候超出範圍...
你檢查你的txt檔資料格式,是不是有些資料少了空格


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
jimwayne





發文: 220
積分: 0
於 2014-02-07 12:00 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
huangbb12345 wrote:
對耶 謝謝你!
但我修改完後錯誤依然存在
InsertDB Exception :java.sql.SQLException: Parameter index out of range (0 < 1 ).

我知道錯誤訊息是告訴我185行有問題
但是陣列不是都是從0開始嗎@@?
我不知道應該修改哪邊才對... Sad


陣列是從 0 開始沒錯,但他出現的問題是 SQL 的問題,並不是原生的陣列問題
而錯誤訊息已經明確說明了索引必須從 1 開始。
例如用 JDBC 使用 Prepare Statement 時,setString() 等方法的索引起始值是 1。

PS. 官方文件:http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html#setString(int, java.lang.String)
文件中可以看到如下的描述
parameterIndex - the first parameter is 1, the second is 2, ...


jimwayne edited on 2014-02-07 12:06
reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:lasaka]
huangbb12345





發文: 19
積分: 0
於 2014-02-07 12:00 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
txt檔空格我已經修改完了,但還是一樣錯誤

reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
huangbb12345





發文: 19
積分: 0
於 2014-02-07 12:16 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
huangbb12345 wrote:
txt檔空格我已經修改完了,但還是一樣錯誤


我若將程式改成
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
package db;
 
import java.io.File;
import java.io.IOException;
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.PreparedStatement; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.sql.Statement; 
import java.util.Scanner;
 
public class jdbcmysql2
{ 
  private Connection con = null; //Database objects 
  //連接object 
  private Statement stat = null; 
  //執行,傳入之sql為完整字串 
  private ResultSet rs = null; 
  //結果集 
  private PreparedStatement pst = null; 
  //執行,傳入之sql為預儲之字申,需要傳入變數之位置 
  //先利用?來做標示 
  
  private String dropdbSQL = "DROP TABLE udp2 "; 
  
  private String createdbSQL = "CREATE TABLE udp2 ("+"item INTEGER"+",lifetime VARCHAR(255)"+",count INTEGER)"; 
  
  private String insertdbSQL = "insert into udp2(item,lifetime,count)"+"select ifNULL(max(item),0)+1,?,? FROM udp2 "; 
  
  private String selectSQL = "select * from udp2 "; 
  
  public jdbcmysql2() 
  { 
    try 
    { 
      Class.forName("com.mysql.jdbc.Driver"); 
      //註冊driver 
      con = DriverManager.getConnection( 
          "jdbc:mysql://localhost/udp?useUnicode=true&characterEncoding=Big5","root","test"); 
      //取得connection
 
      //jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5
      //localhost是主機名,test是database名
      //useUnicode=true&characterEncoding=Big5使用的編碼 
      
    } 
    catch(ClassNotFoundException e) 
    { 
      System.out.println("DriverClassNotFound :"+e.toString()); 
    }//有可能會產生sqlexception 
    catch(SQLException x) 
    { 
      System.out.println("Exception :"+x.toString()); 
    } 
    
  } 
  //建立table的方式 
  //可以看看Statement的使用方式 
  public void createTable() 
  { 
    try 
    { 
      stat = con.createStatement(); 
      stat.executeUpdate(createdbSQL); 
    } 
    catch(SQLException e) 
    { 
      System.out.println("CreateDB Exception :" + e.toString()); 
    } 
    finally 
    { 
      Close(); 
    } 
  } 
  //新增資料 
  //可以看看PrepareStatement的使用方式 
  public void insertTable(String item, String lifetime, String count) 
  { 
    try 
    { 
      pst = con.prepareStatement(insertdbSQL); 
      
      //pst.setString(0, item); 
      pst.setString(1, lifetime); 
      pst.setString(2, count); 
      pst.executeUpdate(); 
    } 
    catch(SQLException e) 
    { 
      System.out.println("InsertDB Exception :" + e.toString()); 
    } 
    finally 
    { 
      Close(); 
    } 
  } 
  //刪除Table, 
  //跟建立table很像 
  public void dropTable() 
  { 
    try 
    { 
      stat = con.createStatement(); 
      stat.executeUpdate(dropdbSQL); 
    } 
    catch(SQLException e) 
    { 
      System.out.println("DropDB Exception :" + e.toString()); 
    } 
    finally 
    { 
      Close(); 
    } 
  } 
  //查詢資料 
  //可以看看回傳結果集及取得資料方式 
  public void SelectTable() 
  { 
    try 
    { 
      stat = con.createStatement(); 
      rs = stat.executeQuery(selectSQL); 
      System.out.println("Item\t\tLifetime\t\tCount"); 
      while(rs.next()) 
      { 
        System.out.println(rs.getInt("item")+"\t\t"+ 
            rs.getString("lifetime")+"\t\t"+ rs.getString("count")); 
      } 
    } 
    catch(SQLException e) 
    { 
      System.out.println("DropDB Exception :" + e.toString()); 
    } 
    finally 
    { 
      Close(); 
    } 
  } 
  //完整使用完資料庫後,記得要關閉所有Object 
  //否則在等待Timeout時,可能會有Connection poor的狀況 
  private void Close() 
  { 
    try 
    { 
      if(rs!=null) 
      { 
        rs.close(); 
        rs = null; 
      } 
      if(stat!=null) 
      { 
        stat.close(); 
        stat = null; 
      } 
      if(pst!=null) 
      { 
        pst.close(); 
        pst = null; 
      } 
    } 
    catch(SQLException e) 
    { 
      System.out.println("Close Exception :" + e.toString()); 
    } 
  } 
  
 
  public static void main(String[] args) throws IOException 
  { 
    //測看看是否正常 
    jdbcmysql2 test = new jdbcmysql2(); 
    test.dropTable(); 
    test.createTable(); 
    
    Scanner scan = new Scanner(new File("C:\\Users\\Pao\\Desktop\\udp2_result.txt"));
    while (scan.hasNext())
    {
      String perLine = scan.nextLine().trim();
        String[] dataAry = perLine.split(", ");
 
        //System.out.println(dataAry[0]);
        
             
          test.insertTable(dataAry[0], dataAry[1], dataAry[2]); 
          
          test.SelectTable();
        
    }
    
  
  } 
}

他跑出來的結果lifetime和count皆正確(如下)

Item    Lifetime    Count
1    <1,88069>    177
2    <1,88069>    266
3    <1,88069>    712
4    <79070,88069>    9
5    <1,88069>    423
6    <1,88069>    287
7    <1,88069>    136
8    <1,88069>    98
9    <1,88069>    387
10    <87070,88069>    1
11    <87070,88069>    1
12    <1,88069>    1102
13    <76070,88069>    12
14    <86070,88069>    2
15    <1,88069>    230
16    <1,88069>    156
17    <18070,88069>    70

但如果地84行註解去掉以後,他則又會出現錯誤
InsertDB Exception :java.sql.SQLException: Parameter index out of range (0 < 1 ).
所以感覺現在問題是在第86行不知道為什麼錯@@?
要如何改才能讓item欄位正確存進txt檔中的第一個欄位呢?


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
jimwayne





發文: 220
積分: 0
於 2014-02-07 12:26 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
huangbb12345 wrote:
但如果地84行註解去掉以後,他則又會出現錯誤
InsertDB Exception :java.sql.SQLException: Parameter index out of range (0 < 1 ).
所以感覺現在問題是在第86行不知道為什麼錯@@?
要如何改才能讓item欄位正確存進txt檔中的第一個欄位呢?


請把程式碼改成:

1
2
3
pst.setString(1, item); 
pst.setString(2, lifetime); 
pst.setString(3, count); 


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:jimwayne]
huangbb12345





發文: 19
積分: 0
於 2014-02-07 12:36 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
jimwayne wrote:
請把程式碼改成:

1
2
3
pst.setString(1, item); 
pst.setString(2, lifetime); 
pst.setString(3, count); 



我也改過,但錯誤就變成
InsertDB Exception :java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2). Dead


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
jimwayne





發文: 220
積分: 0
於 2014-02-07 13:09 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
huangbb12345 wrote:
我也改過,但錯誤就變成
InsertDB Exception :java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2). Dead


那試試看:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public void insertTable(String item, String lifetime, int count) 
  { 
    try 
    { 
      pst = con.prepareStatement(insertdbSQL); 
      
      pst.setString(1, item); 
      pst.setString(2, lifetime); 
      pst.setInt(3, count); 
      pst.executeUpdate(); 
    } 
    catch(SQLException e) 
    { 
      System.out.println("InsertDB Exception :" + e.toString()); 
    } 
    finally 
    { 
      Close(); 
    } 
  }


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
javaX





發文: 188
積分: 0
於 2014-02-07 13:12 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
少了一個?號

reply to postreply to post
教育部:要如何保證畢業即就業
經濟部:所以公司都是我開的
財政部:發前單位請不要幻想能春風化雨
行政院:為什麼該單位發錢的時候都想去當老師
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
alin





發文: 223
積分: 3
於 2014-02-07 13:14 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
insertdbSQL 該SQL語法只有兩個 ?, 所以你設定 1,2,3 當然出錯

reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
jimwayne





發文: 220
積分: 0
於 2014-02-07 13:42 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
huangbb12345 wrote:
我也改過,但錯誤就變成
InsertDB Exception :java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2). Dead


如果您是用中間改過的 SQL(如下)去執行的話...
1
String insertdbSQL = "insert into udp2(item,lifetime,count)"+"select ifNULL(max(item),0)+1,?,? FROM udp2 "; 

就會如樓上大大所說,因為 SQL statement 裡面只有兩個問號,放三個參數當然會出錯....。

不過如果您是用開頭給的 SQL(如下)去執行
1
String insertdbSQL = "insert into udp2(item,lifetime,count) VALUES(?,?,?) from udp2 "; 

但還是出現這個問題的話,也許可以試試看調整參數的型別看看....
(count 在宣告時是 Integer 型別,使用 setString 的方法去插入有可能會有問題)


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:jimwayne]
huangbb12345





發文: 19
積分: 0
於 2014-02-07 17:24 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
jimwayne wrote:
如果您是用中間改過的 SQL(如下)去執行的話...
1
String insertdbSQL = "insert into udp2(item,lifetime,count)"+"select ifNULL(max(item),0)+1,?,? FROM udp2 "; 

就會如樓上大大所說,因為 SQL statement 裡面只有兩個問號,放三個參數當然會出錯....。

不過如果您是用開頭給的 SQL(如下)去執行
1
String insertdbSQL = "insert into udp2(item,lifetime,count) VALUES(?,?,?) from udp2 "; 

但還是出現這個問題的話,也許可以試試看調整參數的型別看看....
(count 在宣告時是 Integer 型別,使用 setString 的方法去插入有可能會有問題)


我有試著改參數的type,但問題依然存在,還想不通到底應該改哪裡才能讓item存進DB...QQ


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
javaX





發文: 188
積分: 0
於 2014-02-07 17:33 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
String[] dataAry = perLine.split(", ");

reply to postreply to post
教育部:要如何保證畢業即就業
經濟部:所以公司都是我開的
財政部:發前單位請不要幻想能春風化雨
行政院:為什麼該單位發錢的時候都想去當老師
作者 Re:如何修改(error:Parameter index out of range) [Re:huangbb12345]
lasaka





發文: 32
積分: 0
於 2014-02-07 17:59 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
用一開始的版本測試過是可以的,但是這句有錯:
private String insertdbSQL = "insert into udp2(item,lifetime,count) VALUES(?,?,?) from udp2 ";

最後的 from udp2 拿掉八這是錯誤的語法

正確的 :
insert into udp2(item,lifetime,count) VALUES(?,?,?)


reply to postreply to post
作者 Re:如何修改(error:Parameter index out of range) [Re:lasaka]
huangbb12345





發文: 19
積分: 0
於 2014-02-07 18:48 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
lasaka wrote:
用一開始的版本測試過是可以的,但是這句有錯:
private String insertdbSQL = "insert into udp2(item,lifetime,count) VALUES(?,?,?) from udp2 ";

最後的 from udp2 拿掉八這是錯誤的語法

正確的 :
insert into udp2(item,lifetime,count) VALUES(?,?,?)


可以了!!
非常感謝各位的幫忙 Smile


reply to postreply to post
» JWorld@TW »  Java 新手區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8