当前位置: 代码迷 >> J2SE >> java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 语法异常 (操作符丢失)
  详细解决方案

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 语法异常 (操作符丢失)

热度:143   发布时间:2016-04-24 14:17:44.0
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失)
<%Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
String   url= "jdbc:odbc:email ";
String   user= " ";
String   pwd= " ";
Connection   con=DriverManager.getConnection(url,user,pwd);
Statement   stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
%>
<%
String   sql1= "select   id   from   email ";
ResultSet   rs=stmt.executeQuery(sql1);
rs.last();
id=rs.getRow();
%>
<%
String   sql= "insert   into   email   values( "+id+ ", "+name1+ ", "+name2+ ", "+name3+ ") ";
stmt.executeUpdate(sql);
  %>

------解决方案--------------------
String sql= "insert into email values( "+id+ ", "+name1+ ", "+name2+ ", "+name3+ ") ";
----------------------------
String sql= "insert into email values( ' "+id+ " ', ' "+name1+ " ', ' "+name2+ " ', ' "+name3+ " ') ";

------解决方案--------------------
单引号注意!!! print出来看看! 发了两个?
  相关解决方案