SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]第 1 行: '='
附近有语法错误。-我找了很久没有找到,请指教!
import java.sql.*;
public class UpdateTable{
public static void main(String args[]){
String dbUrl = "jdbc:microsoft:sqlserver://XIAO:1433;DatabaseName=tset";
String user = "sa";
String password = "123";
String UpdateString = "update COFFEES " +
"set SALES = 100 " +
"set TOTAL = TOTAL+100 " +
"where COF_NAME like 'Colombian' ";
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(java.lang.ClassNotFoundException e){
System.out.print("ClassNotFoundException: ");
System.out.println(e.getMessage());
}
try
{
Connection cn=DriverManager.getConnection(dbUrl,user,password);
Statement s=cn.createStatement();
int n=s.executeUpdate(UpdateString);
//System.out.println(n);
s.close();
cn.close();
}catch(SQLException ex){
System.out.println("SQLException: "+ex.getMessage());
}
}
}
附近有语法错误。-我找了很久没有找到,请指教!
import java.sql.*;
public class UpdateTable{
public static void main(String args[]){
String dbUrl = "jdbc:microsoft:sqlserver://XIAO:1433;DatabaseName=tset";
String user = "sa";
String password = "123";
String UpdateString = "update COFFEES " +
"set SALES = 100 " +
"set TOTAL = TOTAL+100 " +
"where COF_NAME like 'Colombian' ";
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(java.lang.ClassNotFoundException e){
System.out.print("ClassNotFoundException: ");
System.out.println(e.getMessage());
}
try
{
Connection cn=DriverManager.getConnection(dbUrl,user,password);
Statement s=cn.createStatement();
int n=s.executeUpdate(UpdateString);
//System.out.println(n);
s.close();
cn.close();
}catch(SQLException ex){
System.out.println("SQLException: "+ex.getMessage());
}
}
}
"set SALES = 100 " +
"set TOTAL = TOTAL+100 " +
"where COF_NAME like 'Colombian' ";
这句你用两格set干什么,改成下面这样试下:
String UpdateString = "update COFFEES " +
"set SALES = 100 ," +
"TOTAL = TOTAL+100 " +
"where COF_NAME like 'Colombian' ";