none
Data base issues with java need a bit of help

    Question

  • Hey guys i need a bit of help i have connected my database to my netbeans and running querries on it works fine However when i try to Build the MasterDetailForm.java i get these errors and the code looks clean no error.....this is the stack trace that's printed

    [EL Info]: 2012-02-22 19:59:23.911--ServerSession(7714704)--EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
    [EL Info]: 2012-02-22 19:59:24.351--ServerSession(7714704)--file:/C:/Users/Xavier/Documents/NetBeansProjects/Testdatabase/build/classes/_localhost\JANGA-PC\XAVIERSERVER:1845;databaseName=Traffic Tickteing SystemPU login successful
    [EL Warning]: 2012-02-22 19:59:24.459--UnitOfWork(17625473)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '1'.
    Error Code: 102
    Exception in thread "AWT-EventQueue-0" Local Exception Stack: 
    Call: SELECT TRN Number, Address 1, Address 2, Date Of Birth, Expiry Date, First Name, Last Name, Middle Initial, Points, Ticket Number, Type Of Liscene FROM Traffic Tickteing System.dbo.Offender
    Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
    Query: ReadAllQuery(referenceClass=Offender sql="SELECT TRN Number, Address 1, Address 2, Date Of Birth, Expiry Date, First Name, Last Name, Middle Initial, Points, Ticket Number, Type Of Liscene FROM Traffic Tickteing System.dbo.Offender")
    Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '1'.
    Error Code: 102
    Call: SELECT TRN Number, Address 1, Address 2, Date Of Birth, Expiry Date, First Name, Last Name, Middle Initial, Points, Ticket Number, Type Of Liscene FROM Traffic Tickteing System.dbo.Offender
    Query: ReadAllQuery(referenceClass=Offender sql="SELECT TRN Number, Address 1, Address 2, Date Of Birth, Expiry Date, First Name, Last Name, Middle Initial, Points, Ticket Number, Type Of Liscene FROM Traffic Tickteing System.dbo.Offender")
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:644)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535)
    at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1702)
    at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:566)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:646)
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2592)
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2551)
    at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:418)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1097)
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:829)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1056)
    at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:390)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1144)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1501)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1483)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1457)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
    at testdatabase.NewMasterDetailForm.initComponents(NewMasterDetailForm.java:40)
    at testdatabase.NewMasterDetailForm.<init>(NewMasterDetailForm.java:22)
    at testdatabase.NewMasterDetailForm$1.run(NewMasterDetailForm.java:465)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
    at java.awt.EventQueue.access$000(EventQueue.java:101)
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '1'.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:390)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:283)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:931)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:607)
    ... 38 more
    BUILD SUCCESSFUL (total time: 3 seconds)

    I am running sql server 2008 on win7 x64 using netbeans 7.1 with jdk 1.7 and the latest JVM
    • Edited by Jblacks Thursday, February 23, 2012 1:16 AM
    Thursday, February 23, 2012 1:14 AM

Answers

  • Hello Deepak_Goyal and Jblacks,

    You have forgotten to enclose some fields between brackets ( maybe it is why the query is not working )

    SELECT TRN Number, [Address 1], [Address 2], [Date Of Birth], [Expiry Date], [First Name], [Last Name], [Middle Initial], Points, [Ticket Number], [Type Of Liscene] FROM [Traffic Tickteing System].dbo.Offender

    i am surprised by the Type of Liscene column name.Maybe a little error , i would prefer [Type Of Liscense]

    i am also surprised Traffic Tickteing System. I don't know the tickteing word in english , i would prefer Ticketing ( but as many french people , i am not good in foreign languages and so , i may go wrong )

    http://msdn.microsoft.com/en-us/library/ms175874(v=sql.100).aspx

    you will find

    "When identifiers are used in Transact-SQL statements, the identifiers that do not comply with these rules must be delimited by double quotation marks or brackets"

    The use of brackets avoids any problem of double quotation marks but it may not be supported by other database engines or applications

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.


    • Edited by Papy NormandModerator Monday, February 27, 2012 6:32 PM add remark about Tickteing
    • Marked as answer by KJian_ Wednesday, February 29, 2012 6:15 AM
    Monday, February 27, 2012 6:29 PM

All replies

  • Use your querry in this manner

    Incorrect Query:

    SELECT TRN Number, Address 1, Address 2, Date Of Birth, Expiry Date, First Name, Last Name, Middle Initial, Points, Ticket Number, Type Of Liscene FROM Traffic Tickteing System.dbo.Offender

    Correct Query :

    SELECT TRN Number, [Address 1], [Address 2], Date Of Birth, Expiry Date, First Name, Last Name, Middle Initial, Points, Ticket Number, Type Of Liscene FROM [Traffic Tickteing System].dbo.Offender



    Thursday, February 23, 2012 6:11 AM
  • I tried your solution but it didn't work i think its cuz the querry was autogenerated by netbeans.....i think i might have to do with beanbinding not being compatible with ms sql im not sure but it seems to be the case
    Thursday, February 23, 2012 2:43 PM
  • Hello Deepak_Goyal and Jblacks,

    You have forgotten to enclose some fields between brackets ( maybe it is why the query is not working )

    SELECT TRN Number, [Address 1], [Address 2], [Date Of Birth], [Expiry Date], [First Name], [Last Name], [Middle Initial], Points, [Ticket Number], [Type Of Liscene] FROM [Traffic Tickteing System].dbo.Offender

    i am surprised by the Type of Liscene column name.Maybe a little error , i would prefer [Type Of Liscense]

    i am also surprised Traffic Tickteing System. I don't know the tickteing word in english , i would prefer Ticketing ( but as many french people , i am not good in foreign languages and so , i may go wrong )

    http://msdn.microsoft.com/en-us/library/ms175874(v=sql.100).aspx

    you will find

    "When identifiers are used in Transact-SQL statements, the identifiers that do not comply with these rules must be delimited by double quotation marks or brackets"

    The use of brackets avoids any problem of double quotation marks but it may not be supported by other database engines or applications

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.


    • Edited by Papy NormandModerator Monday, February 27, 2012 6:32 PM add remark about Tickteing
    • Marked as answer by KJian_ Wednesday, February 29, 2012 6:15 AM
    Monday, February 27, 2012 6:29 PM