sqlserver page exception

2010-08-13  来源:本站原创  分类:Java  人气:163 

SQL statement:

String sql = "select top ? * from bbs_posts where p_fid=? order by p_addtime desc";
         prepStmt = conn.prepareStatement(sql);
         prepStmt.setInt(1, xxx);
         prepStmt.setInt(2, xx);
         prepStmt.executeQuery()

Pre-compiled:
Exception:

java.sql.SQLException: '@P0'  Syntax error near  .
     at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
     at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2816)
     at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2254)
     at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:631)
     at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:477)
     at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:777)
     at yixun.wap.db.DBConnection.executeQuery(DBConnection.java:41)
     at yixun.wap.bbs.dao.ForumDAO.get500WANforum(ForumDAO.java:282)
     at yixun.wap.bbs.BbsCache.get500WANforumCache(BbsCache.java:91)
     at yixun.wap.bbs.service.ForumBO.get500WANforum(ForumBO.java:143)
     at _jsp._page._bbs._space._second__jsp._jspService(_second__jsp.java:83)

Reason: sql does not support the select top? Pre-compiled and replaced with dynamic mosaic

String sql = "select top %s * from bbs_posts where p_fid=? order by p_addtime desc";
         sql = String.format(sql, num);
相关文章
  • sqlserver page exception 2010-08-13

    SQL statement: String sql = "select top ? * from bbs_posts where p_fid=? order by p_addtime desc"; prepStmt = conn.prepareStatement(sql); prepStmt.setInt(1, xxx); prepStmt.setInt(2, xx); prepStmt.executeQuery() Pre-compiled: Exception: java.sql.

  • mysql.sqlserver.oracle pages, java unified interface page 2011-07-12

    Definition: pageStart start page, pageEnd end page, pageSize the page size oracle page: select * from (select mytable .*, rownum num from (the actual transfer of SQL) where rownum <= pageEnd) where num> = pageStart sqlServer Page: select * from (sel

  • jsp直连mysql数据库,SQLserver数据 测试数据库可用页面 2013-07-01

    好吧,平时难免有时候连接不上数据库,最常用的方法就是写个页面看看能不能连接上数据库,现将代码记录如下: (jar包必须要有) mysql <%@page contentType="text/html;charset=utf-8" import="java.sql.*%> <% String driver = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost

  • Struts1x project development in a unified exception handling 2008-11-30

    In the project development if we can use a unified exception handling, then not only can simplify the development process, but also easier to team development and cooperation more efficiently. The following combination of achievement through the use

  • JSP Study Notes 2 - The page compiler directive directive 2010-04-07

    JSP directive will be converted to the corresponding JSP engine's Java code, but these Java code does not directly produce any visible Shuchu but to inform the JSP engine Ruhe Processing JSP pages, Servlet classes Huoshi how Sheng Cheng. JSP directiv

  • struts2 global exception prompted to use custom properties file 2010-07-25

    # Type conversion tips xwork.default.invalid.fieldvalue={0} Type conversion errors ~~~ Properties file "(0)" is actually placeholder symbol, if there are multiple attributes of type conversion has an exception occurs, may turn to "(0 }"

  • exception --- struts1 2010-08-25

    On the struts in the exception handling, use dynamic actionform, without the need to write code, just configure in the configuration file can be New web project in myeclipse ch04exception, add the struts properties New action, new tools will automati

  • Linux kernel for the page into 2010-08-30

    The page table entry and page directory P flag to 0 that the corresponding physical page is not in memory, which can not complete the visit, cpu will generate a missing page exception. When pages in memory, the page table entry is a pet_t structure,

  • webSphere portal InvocationTargetException exception problem 2011-03-18

    The SystemOut.log at the time of the exception displays content similar to the following snippet: [1/19/09 14:41:22:877 PST] 00000045 WebApp E SRVE0026E: [Servlet Error]-[JSPG0227E: Exception caught while translating /ConsumerDirectStorefrontAssetSto

  • Abnormal Mdx query collection (2) 2010-07-25

    Earlier I have compiled some common abnormalities mdx query, and then posted here I encountered in the process of learning some other common abnormalities. Some have been resolved, there are a number of unresolved hope is to learn and become familiar

  • resion 2.x Configuration 2010-12-14

    resion 2.x Configuration 1. <http Host='localhost' port='8888'/> parameter specifies the server host, port http port is specified, the default is localhost and 8080. 2. <srun Host='localhost' port='6802'/> This is the jsp and java Servlet engi

  • SQL2005 and lock in the transaction 2011-08-17

    Source: http://blog.csdn.net/happyflystone Finally settled down to write an article for this transaction and lock, only to find really difficult to write to write, transactions, affairs and lock this topic too complex, and even some also touched (tha

  • Struts2 Interceptor (Interceptor) 2010-03-29

    1. Understand the interceptor 1.1. What is the interceptor: Interceptors, in the AOP (Aspect-Oriented Programming) is used in a method or field has been visited before, before or after the block and then adding some operations. AOP interception is an

  • Using struts2 interceptor 2008-05-23

    How to use struts2 interceptors, or the custom interceptors. Special attention in the use of interceptors, when, in the Action which must finally be sure to reference the interceptor struts2 own default stack defaultStack, as follows (where I was quo

  • jsp9 large built-in objects summary 2010-03-30

    Built-in object type scope request javax.servlet.http.HttpServletRequest request response javax.servlet.http.HttpServletResponse page pageContext javax.servlet.jsp.PageContext page session javax.servlet.http.HttpSession session application javax.serv

  • JSP built-in objects Xiang Jie - rpm 2010-03-23

    jsp nine built-in objects: request, reponse, out, session, application, config, pagecontext, page, exception. 1. Request object: This object encapsulates the information submitted by users, by calling the appropriate method of the object can access t

  • To start the application process appears abnormal SpringSide ~ 2010-03-17

    Version: SpringSide3.2.2 Database: MySql5.0 Exception 1: ognl.OgnlException: target is null for setProperty(null, "pageNo", [Ljava.lang.String;@18a80d4) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2219) at ognl.ASTProperty.setValueBody(ASTP

  • struts2 interceptor and explain specific 2010-04-04

    Interceptor Name Explain Alias Interceptor alias In the different requests and the request parameter names in different parts change, the contents of the same request Chaining Interceptor chain To the previous Action's properties can be an Action aft

  • JSP9 large built-in objects 2010-04-16

    1, out: JspWriter out object is an instance of the class is the common output to the client object; JSP's output stream, equivalent to the expression; out.println ("test"); 2, request: The client request information to be encapsulated in the req

  • Implementation of dynamic ajax tree 2010-06-01

    1. Design: 1. Layout css + div: good is not to say 2. Using ajax, when clicking the tree when a node generates its child nodes, so the client can avoid the one-time loads the whole tree, the implementation of fast 3. Tree formation control using java