我正在使用 sql server 2005。我想在 sql server 2005 中对具有数据类型 Varchar(20) 的列名称使用 RTRIM 函数,但它给出了错误('(') 附近的语法不正确。
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:project","sa","123456");
PreparedStatement stmt= con.prepareStatement("insert into driver (RTRIM(Name),Address,Email,Homeph,Cellph,Startdate,Hourlyrate,Image) values(?,?,?,?,?,?,?,?)");
stmt.setString(1,tx_name.getText());
stmt.setString(2,tx_address.getText());
stmt.setString(3,tx_email.getText());
stmt.setInt(4,Integer.parseInt(tx_homeph.getText()));
stmt.setInt(5,Integer.parseInt(tx_cellph.getText()));
String date=cb_date.getSelectedItem().toString()+"-"+cb_month.getSelectedItem().toString()+"-"+cb_year.getSelectedItem().toString();
stmt.setString(6,date);
stmt.setInt(7,Integer.parseInt(tx_hourlyrate.getText()));
stmt.setString(8,tx_image.getText());
stmt.executeUpdate();
JOptionPane.showMessageDialog(f,"Data Saved","Save",JOptionPane.INFORMATION_MESSAGE);
}
catch(Exception en)
{
JOptionPane.showConfirmDialog(f,en);
}