SQLException syntax error in query
I am baffled and hoping that maybe you can spot an error in my query - I can't seem to find it!
The query is:
INSERT INTO CreditCard (userID, type, name, number, expiration, addressID) VALUES (5, 1, 'Bill', '1264', 2004-04-10, 9)
And in code it is:
String sql = "INSERT INTO CreditCard (userID, type, name, number," + " expiration, addressID) VALUES (" + userId + ", " + type + ", \'" + name + "\', \'" + number + "\', " + expiration + ", " + addressId + ")";
I keep getting error for this line:
stmt.execute(sql);
with the following message:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3065)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at jauction.server.CreditCardImpl.<init>(CreditCardImpl.java:65)
at jauction.server.CreditCardTest.main(CreditCardTest.java:14)
Do you spot the syntax error in the query? Is there any other reason why I could be getting this error?
Similar INSERT INTO queries have been implemented and tested in this project of mine and they are working fine. I am baffled as to where the syntax error is in this query. If you spot it - could you point it out? Thanks.
Thanks man, you saved me hours of debugging.
I had an Access table with a column named TimeStamp, just couldn't get the damn thing to work. But I think both our problems are JDBC/SQL related, not Access related. In other words, it wouldn't work on any other RDBMS system either.
Someone should put it in the documentation somewhere that using SQL datatype names for column names is a no-no.
Similar Messages
-
TNG_recordset Syntax error in query. Incomplete query clause.
I'm using the ADDT insert record form wizard and I keep getting this error: Syntax error in query. Incomplete query clause. Can anyone help?
<br />
<br /><%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<br />
<!--#include file="../Connections/rentalpaypro.asp" -->
<br />
<!--#include file="../includes/common/KT_common.asp" -->
<br />
<!--#include file="../includes/tNG/tNG.inc.asp" -->
<br /><%<br />'Start log out user<br /> Set logout = new tNG_Logout<br /> logout.setLogoutType "link"<br /> logout.setPageRedirect "../index.html"<br /> logout.Execute<br />'End log out user<br />%>
<br /><%<br />'Make a transaction dispatcher instance<br />Dim tNGs: Set tNGs = new tNG_dispatcher<br />tNGs.Init "../"<br />%>
<br /><%<br />' Start trigger<br />Dim formValidation: Set formValidation = new tNG_FormValidation<br />formValidation.Init<br />formValidation.addField "ContactFirstName", true, "text", "", "", "", ""<br />formValidation.addField "ContactLastName", true, "text", "", "", "", ""<br />formValidation.addField "EmailAddress", true, "text", "email", "", "", ""<br />formValidation.addField "BillingAddress", true, "text", "", "", "", ""<br />formValidation.addField "City", true, "text", "", "", "", ""<br />formValidation.addField "StateOrProvince", true, "text", "", "", "", ""<br />formValidation.addField "ZipCode", true, "numeric", "", "", "", ""<br />formValidation.addField "PhoneNumber", true, "text", "", "", "", ""<br />tNGs.prepareValidation formValidation<br />' End trigger<br />%>
<br /><%<br />'Start Restrict Access to Page<br /> Dim restrict: Set restrict = new tNG_RestrictAccess<br /> restrict.Init MM_rentalpaypro_STRING, "../"<br />'Grand Levels: Any<br /> restrict.Execute<br />'End Restrict Access to Page<br />%>
<br /><%<br />' Make an insert transaction instance <br />Dim ins__Landlord_Contact_Info_: Set ins__Landlord_Contact_Info_ = new tNG_insert<br />ins__Landlord_Contact_Info_.init MM_rentalpaypro_STRING<br />tNGs.addTransaction ins__Landlord_Contact_Info_<br />' Register triggers<br />ins__Landlord_Contact_Info_.registerTrigger Array("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1")<br />ins__Landlord_Contact_Info_.registerTrigger Array("BEFORE", "Trigger_Default_FormValidation", 10, formValidation)<br />ins__Landlord_Contact_Info_.registerTrigger Array("END", "Trigger_Default_Redirect", 99, "index.asp")<br />' Add columns<br />ins__Landlord_Contact_Info_.setTable ""Landlord_Contact Info""<br />ins__Landlord_Contact_Info_.addColumn "ContactFirstName", "STRING_TYPE", "POST", "ContactFirstName", ""<br />ins__Landlord_Contact_Info_.addColumn "ContactLastName", "STRING_TYPE", "POST", "ContactLastName", ""<br />ins__Landlord_Contact_Info_.addColumn "EmailAddress", "STRING_TYPE", "POST", "EmailAddress", ""<br />ins__Landlord_Contact_Info_.addColumn "BillingAddress", "STRING_TYPE", "POST", "BillingAddress", ""<br />ins__Landlord_Contact_Info_.addColumn "City", "STRING_TYPE", "POST", "City", ""<br />ins__Landlord_Contact_Info_.addColumn "CompanyName", "STRING_TYPE", "POST", "CompanyName", ""<br />ins__Landlord_Contact_Info_.addColumn "StateOrProvince", "STRING_TYPE", "POST", "StateOrProvince", ""<br />ins__Landlord_Contact_Info_.addColumn "ZipCode", "NUMERIC_TYPE", "POST", "ZipCode", ""<br />ins__Landlord_Contact_Info_.addColumn "Extension", "STRING_TYPE", "POST", "Extension", ""<br />ins__Landlord_Contact_Info_.addColumn "FaxNumber", "STRING_TYPE", "POST", "FaxNumber", ""<br />ins__Landlord_Contact_Info_.addColumn "PhoneNumber", "STRING_TYPE", "POST", "PhoneNumber", ""<br />ins__Landlord_Contact_Info_.setPrimaryKey "ContactInfoID", "NUMERIC_TYPE", "", ""<br />%>
<br /><%<br />'Execute all the registered transactions<br />tNGs.executeTransactions<br />%>
<br /><%<br />'Get the transaction recordset<br />Dim rs_Landlord_Contact_Info_<br />Dim rs_Landlord_Contact_Info__numRows<br /><br />Set rs_Landlord_Contact_Info_ = tNGs.getRecordset(""Landlord_Contact Info"")<br />rs_Landlord_Contact_Info__numRows = 0<br />%>Are you sure that you are passing the querystring customerid
when the form
company_cus is empty.
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver
Valleybiz Internet Design
www.valleybiz.net
"aonefun" <[email protected]> wrote in
message
news:epmf3n$f3u$[email protected]..
>I am receiving the following error message:
>
> Microsoft][ODBC Microsoft Access Driver] Syntax error
(missing operator)
> in
> query expression 'customerid_cus='.
>
> for the following code:
>
> If IsEmpty(Request.Form("company_cus")) Then
>
> rs_company.Source = "SELECT customerid_cus, company_cus
FROM
> customers_cus
> WHERE customerid_cus= "&
Request.QueryString("customerid") &" "
>
> Else
>
> rs_company.Source = "SELECT customerid_cus, company_cus
FROM
> customers_cus
> WHERE company_cus = '"& Request.Form("company_cus")
>
> End If
>
> What could the problem be?
> -
Syntax error (parsing query)
I'm trying to search based on two properties and got an exception:
syntax error (parsing query);location=trexsahqt1v:30003 (Errorcode 2029)
If i set only one condition my code is working fine
My code....
for(int i = 0; i < searchParams.length; i++)
IQueryEntry queryEntry = indexCollection.getNewQueryEntry()
if ("createdby".equalsIgnoreCase(searchParams<i>.getPropertyName()))
queryEntry.setRowType(IQueryEntry.ROW_TYPE_ATTRIBUTE);
queryEntry.setTermAction(IQueryEntry.TERM_ACTION_EXACT);
queryEntry.setPropertyName(PropertyName.createCreatedBy());
queryEntry.setValue("same value")
queryEntry.setPropertyOperator(IQueryEntry.PROPERTY_OPERATOR_EQUAL);
queryEntryList.add(queryEntry);
if ("modifiedby:".equalsIgnoreCase(searchParams<i>.getPropertyName()))
queryEntry.setRowType(IQueryEntry.ROW_TYPE_ATTRIBUTE);
queryEntry.setTermAction(IQueryEntry.TERM_ACTION_EXACT);
queryEntry.setPropertyName(PropertyName.createCreatedBy());
queryEntry.setValue("same value");
queryEntry.setPropertyOperator(IQueryEntry.PROPERTY_OPERATOR_EQUAL);
queryEntryList.add(queryEntry);
Is any "AND" or "OR" operators I have to setup , if yes please let me know how?
Really appreciate your helpI'm trying to search based on two properties and got an exception:
syntax error (parsing query);location=trexsahqt1v:30003 (Errorcode 2029)
If i set only one condition my code is working fine
My code....
for(int i = 0; i < searchParams.length; i++)
IQueryEntry queryEntry = indexCollection.getNewQueryEntry()
if ("createdby".equalsIgnoreCase(searchParams<i>.getPropertyName()))
queryEntry.setRowType(IQueryEntry.ROW_TYPE_ATTRIBUTE);
queryEntry.setTermAction(IQueryEntry.TERM_ACTION_EXACT);
queryEntry.setPropertyName(PropertyName.createCreatedBy());
queryEntry.setValue("same value")
queryEntry.setPropertyOperator(IQueryEntry.PROPERTY_OPERATOR_EQUAL);
queryEntryList.add(queryEntry);
if ("modifiedby:".equalsIgnoreCase(searchParams<i>.getPropertyName()))
queryEntry.setRowType(IQueryEntry.ROW_TYPE_ATTRIBUTE);
queryEntry.setTermAction(IQueryEntry.TERM_ACTION_EXACT);
queryEntry.setPropertyName(PropertyName.createCreatedBy());
queryEntry.setValue("same value");
queryEntry.setPropertyOperator(IQueryEntry.PROPERTY_OPERATOR_EQUAL);
queryEntryList.add(queryEntry);
Is any "AND" or "OR" operators I have to setup , if yes please let me know how?
Really appreciate your help -
Syntax error in query expression
I am receiving the following error message:
Microsoft][ODBC Microsoft Access Driver] Syntax error
(missing operator) in query expression 'customerid_cus='.
for the following code:
If IsEmpty(Request.Form("company_cus")) Then
rs_company.Source = "SELECT customerid_cus, company_cus FROM
customers_cus WHERE customerid_cus= "&
Request.QueryString("customerid") &" "
Else
rs_company.Source = "SELECT customerid_cus, company_cus FROM
customers_cus WHERE company_cus = '"&
Request.Form("company_cus") &"' "
End If
What could the problem be?Are you sure that you are passing the querystring customerid
when the form
company_cus is empty.
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver
Valleybiz Internet Design
www.valleybiz.net
"aonefun" <[email protected]> wrote in
message
news:epmf3n$f3u$[email protected]..
>I am receiving the following error message:
>
> Microsoft][ODBC Microsoft Access Driver] Syntax error
(missing operator)
> in
> query expression 'customerid_cus='.
>
> for the following code:
>
> If IsEmpty(Request.Form("company_cus")) Then
>
> rs_company.Source = "SELECT customerid_cus, company_cus
FROM
> customers_cus
> WHERE customerid_cus= "&
Request.QueryString("customerid") &" "
>
> Else
>
> rs_company.Source = "SELECT customerid_cus, company_cus
FROM
> customers_cus
> WHERE company_cus = '"& Request.Form("company_cus")
>
> End If
>
> What could the problem be?
> -
11g gateway for ODBC returns SYNTAX ERROR on query
Hi,
I have made a database link to an odbc link on a 11g gateway. The odbc driver for the database in question is called connx, a third party driver to connect to RMS files on an old vax. The odbc driver works fine as I tested it independently of the gateway.
The database link connection is fine. I do desc tablename and it returns the correct columns
I do for example select * from SICF090MLT@melt and it returns :
meltdb>select * from SICF090MLT@melt;
select * from SICF090MLT@melt
ERROR at line 1:
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
Illegal identifier
A1."CHARGE_NO" , A1."MIX_ID" , A1."BUCKET_ID" , A1."AIM_ST" , A1."SCRAP_MIX_NAME" FROM << Syntax Error >> 'SICF090MLT' A1
ORA-02063: preceding 3 lines from MELT
As you can see all of the columns have been discovered by the query,
I am not sure what can be the issue. Maybe a character translation issue? Some configuration settings for the gateway? Any ideas?
On a side note: all other database links to other databases (sqlserver) work fine with this 11g gateway.
The Best to all of you!Mireille,
I am using a win32 driver.
HS_FDS_SUPPORT_STATISTICS is false for all my database links. I have had issues with that in the past and have already learned my lesson :)
I will check the quoted identifier setting for my odbc link and change it if I can.
As a side note: for now I am using the DBMS_HS_PASSTHROUGH package to get around the problem, but it is better if I solve my original problem obviously. I will let you know.
Merci et bonne journée. -
Syntax error on query generation
Hi,
When I try to generate report syntax error occures. It's not a custom code. What do you think about it ?
(syntax error in the following code:
return.
perform Debug_xfems.
See some piece of generated file :
REPORT RSRRNAME.
FORM SELECT_4.
if G_S_QCF-cmess eq rrkg_C_cmess-error.
perform CU_MESS_send.
endif.
read Table <G_THX_s> assigning <G_SX_S>
with table key k = G_SX_s-k.
if sy-subrc gt 0.
insert G_SX_S into table <G_THX_S> assigning <G_SX_S>.
endif.
ENDFORM.
FORM MOVE_Z_SP_0001.
ENDFORM.
return.
perform Debug_xfems.
form check_fems using value(I_fems) type i.
perform I_fems of " REP I_FEMS = 2
MOVE_Z_SP_0001
DEBUG_XFems.
endform. " now look at G_TSX_XFems
Thanks in advance.
Fiodar.Hi,
I would suggest that you check OSS for existing SAP notes on the issue and if you find nothing, please create a SAP customer message.
All the best,
Mike -
Can someone fix this query for me? I have been at it for an hour and can't locate the rogue error
ISNULL(CAST(CONVERT(DECIMAL(18,4)(COUNT(CASE WHEN soldStatus IN ('Yes', 'Pending') THEN saleTotal ELSE NULL END))) AS FLOAT)/NULLIF(CAST(CONVERT(DECIMAL(18,4),(COUNT(DISTINCT(saleTotal))) AS FLOAT),0),0) As PercentageHello Joe,
You should format your T-SQL more proper, then it's easier to read and easier to find mistakes:
ISNULL(CAST(CONVERT(DECIMAL(18,4),
(COUNT(CASE WHEN soldStatus IN ('Yes', 'Pending')
THEN saleTotal
ELSE NULL END))) AS FLOAT)
/NULLIF(CAST(CONVERT(DECIMAL(18,4), COUNT(DISTINCT(saleTotal))) AS FLOAT),0),0) As Percentage
1. First line, there was a comma behind DECIMAL(18,4), missunt
2. Last line, one opening bracket before COUNT to much
Olaf Helper
[ Blog] [ Xing] [ MVP] -
Query syntax error after multiprovider change
Hi everyone,
I removed key figures from a multicube, changed a query on top afterwards and saved it. The key figures are no longer in the key figure list of the query in the Query designer, and are no longer used in any place within the query.
Now, I'm getting a syntax error on query execution, since the compiled query still contains a reference to the old key figures. Regeneration via RSRT or saving under a new name doesn't work, and to delete the generated report I need a developer key.
Any ideas?
Regards,
TilmanHi Shashank,
thanks for your response.
I did try the "check query" button, it didn't return an error. When executing the query via rsrt, I get a dump due to "Syntax error in program GP48VM7K0MSF08DRO2382A2PSTI ". The program still contains data type references to the removed infoobjects. When checking the program via SE38, you get just that syntax error.
I'm looking for a way to clean these things up. Even when creating a new query on the aggregation level (I was talking about a multiprovider earlier, which is located underneath), the error pops up. I activated all the objects along the way, with no effect.
Regards,
Tilman -
PreparedStatment creating Syntax Error.
The poblem is in the first prepared statment if I enter the value straight into the statement string everying works fine. However, when I use a ? for placeholder and then supply the same sting value i would have entered in the statement string I get a sytax error.
import java.sql.*; import javax.swing.*; import java.awt.BorderLayout; import java.awt.event.*; public class Exercise34_5 extends JFrame { private JTextField jtfInput = new JTextField(10); private JButton jbShowTable = new JButton("Show Table"); private JTextArea jta = new JTextArea(); private PreparedStatement pstmt1; private PreparedStatement pstmt2; private PreparedStatement pstmt3; public Exercise34_5() { JPanel northPanel = new JPanel(); northPanel.add(new JLabel("Table Name")); northPanel.add(jtfInput); northPanel.add(jbShowTable); add(northPanel, BorderLayout.NORTH); add(new JScrollPane(jta)); try { Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/test" , "root", "root"); pstmt1 = connection.prepareStatement("describe ?"); pstmt2 = connection.prepareStatement("select count(*) from enrollment"); pstmt3 = connection.prepareStatement("select * from enrollment"); }catch(Exception ex) { ex.printStackTrace(); } jbShowTable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String table = jtfInput.getText(); try{ pstmt1.setString(1, "enrollment"); /*pstmt2.setString(1, "enrollment"); pstmt3.setString(1, "enrollment");*/ ResultSet rset1 = pstmt1.executeQuery(); ResultSet rset3 = pstmt3.executeQuery(); int count = 0; while(rset1.next()) { jta.append(rset1.getString(1) + "\t"); count++; } jta.append("\n"); System.out.println(count); while(rset3.next()) { for(int i = 1; i <= count; i++) { jta.append(rset3.getString(i) + "\t"); } jta.append("\n"); } }catch(Exception ex) { ex.printStackTrace(); } } }); } public static void main(String[] args) { Exercise34_5 frame = new Exercise34_5(); frame.setSize(400, 200); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setVisible(true); } }
java.sql.SQLException: Syntax error or access violation message from server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''enrollment'' at line 1"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2251)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)
at Exercise34_5$1.actionPerformed(Exercise34_5.java:47)Alyosha wrote:
I don't understand.You can't just put a ? parameter any old place in a prepared statement. It's just just a simple string substitution. For instance, you cannot use a ? parameter for a table name or a column name.
// wrong
ps = conn.prepareStatement("select * from ? where ? = ?");
ps.setString(1, tableName);
ps.setString(2, columnName);
ps.setString(3, columnValue);
// right
ps = conn.prepareStatement("select * from " + tableName = " where " + columnName + " = ?");
ps.setString(1, columnValue); -
Syntax Errors in Recordset, Dreamweaver 8
Hi All!
I'm struggling to figure out Dreamweaver's syntax for a Recordset I'm building. I'm using Dreamweaver 8, ColdFusion 9 to connect with my database, and Windows 7.
I have to start by admitting I copied code from an similar program, and am trying to get it to work for me.
Here's the error I get when I "test" the recordset:
Syntax error. in query expression '1=1
Here's the query:
SELECT LastName, FirstName, MiddleName, Generation, PartyType
FROM [Party Information]
WHERE 1=1
SELECT FullCaseNo, DocketSheet
FROM [Case Information]
WHERE 1=1
<cfif IsDefined("Form.LastName") and Form.LastName NEQ "">
AND PartyInformation.Last Like'#Form.LastName#%'
</cfif>
<cfif IsDefined("Form.FirstName") and Form.FirstName NEQ "">
AND PartyInformation.First Like'#Form.FirstName#%'
</cfif>
<cfif IsDefined("Form.CaseNo") and Form.CaseNo NEQ "">
AND CaseInformation.FullCaseNo ='#Form.CaseNo#'
</cfif>
ORDER BY LastName, FirstName, MiddleName, FullCaseNo
For the sake of just seeing I deleted "WHERE 1=1" just to see if it would run, and I got another syntax error in the FROM clause. In case this wasn't already obvious I'm brand new to Dreamweaver and just trying to get this thing to work.
Any help is much appreciated, thanks in advance!!That's sad to hear.
Anyway, if you're continuing to work on this, why dont you try replacing this:
SELECT LastName, FirstName, MiddleName, Generation, PartyType
FROM [Party Information]
WHERE 1=1
with this:
SELECT LastName, FirstName, MiddleName, Generation, PartyType
FROM PartyInformation
WHERE 0=1
WHERE 1=1 is usually a SQL code to prevent injections and to increase performance of the query you're running.
WHERE 0=1 will usually look up all records in the table you're querying into - this is what you're trying to achieve here anyway.
and rename the table on your DB from Party Information to PartyInformation -
hi,
i have an error with my sql statement and i try to find the error but i couldn't could you please help me to find the error in this statement.
sql.append("SELECT * FROM CARS WHERE TO_DAYS('");
sql.append(PickDat + "') >= TO_DAYS('FROM_D')");
sql.append("AND TO_DAYS('");
sql.append(DropDat + "') <= TO_DAYS('UNTIL_D')");
sql.append("AND PICK_UP_DROP ='");
sql.append(pickdropPnt + "'AND CAR_TYPE ='");
sql.append(carclass + "'");
error message :
java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near '' at line 1 java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near '' at line 1
thanks,
yuetNihi,
thanks for your reply, i tried to use your idea but it still give me an error which i couldn't understand it.
is it ok if i use the code below to convert a String to Date.
java.sql.Date PickDat = java.sql.Date.valueOf(PDate);
java.sql.Date DropDat = java.sql.Date.valueOf(DDate);
System.out.println("IN CARINFO FUNC." + pickdropPnt + PDate + DDate + carclass);
sql.append("SELECT * FROM CARS");
sql.append("WHERE TO_DAYS('" PickDat "') BETWEEN TO_DAYS('FROM_D') AND TO_DAYS('UNTIL_D') ");
sql.append("AND TO_DAYS('" DropDat "') BETWEEN TO_DAYS('"+PickDat+"') AND TO_DAYS('UNTIL_D') ");
sql.append("AND PICK_UP_DROP ='" + pickdropPnt +"' ");
sql.append("AND CAR_TYPE ='"+carclass + "'");
thanks for your help
regards,
yuetNiSwee -
Derby - Syntax error, why?
Hello,
I'm stumped as to why this doesn't work (the commented part works fine)
try { String connn = "jdbc:derby:test;create=true"; Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); Connection connect = DriverManager.getConnection( connn ); // Statement stat; // stat = connect.createStatement(); // stat.executeUpdate( "CREATE TABLE City ( NAME VARCHAR(35) NOT NULL )" ); // // Statement st; // st = connect.createStatement(); // st.executeUpdate("INSERT INTO City( Name ) " + // "VALUES( 'Amsterdam' )" ); // // PreparedStatement statement = connect.prepareStatement("SELECT Name FROM City"); // ResultSet resultSet = statement.executeQuery(); // while (resultSet.next()) { // System.out.println( resultSet.getString("Name") ); // } Statement stat; stat = connect.createStatement(); stat.executeUpdate( "CREATE TABLE weerstations ( "+ "stationsnummer VARCHAR(5) NOT NULL, "+ "voortzetting VARCHAR(5),"+ "naam String NOT NULL, "+ "positie string NOT NULL, "+ "terreinhoogte DOUBLE(2, 1), "+ "karakteristiek string NOT NULL, "+ "grondsoort string NOT NULL, "+ "barometer DOUBLE(3, 1), "+ "windmeetmast INT(2)" ); } catch( Exception e ) { e.printStackTrace(); } finally{ System.exit( 1); }
The error it throws is
java.sql.SQLSyntaxErrorException: Syntax error: Encountered "String" at line 1, column 110. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(Unknown Source) at Database.<init>(Database.java:49) at DatumSelectiePanel.<init>(DatumSelectiePanel.java:25) at WeerApp.<init>(WeerApp.java:88) at Test.createAndShowGUI(Test.java:32) at Test.access$0(Test.java:25) at Test$1.run(Test.java:49) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:226) at java.awt.EventQueue.dispatchEvent(EventQueue.java:602) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177) at java.awt.EventDispatchThread.run(EventDispatchThread.java:138) Caused by: java.sql.SQLException: Syntax error: Encountered "String" at line 1, column 110. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) ... 22 more Caused by: ERROR 42X01: Syntax error: Encountered "String" at line 1, column 110. at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source) at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source) at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source) ... 16 more
(line 49 is stat.executeUpdate()Ah yes, cut off the parenthesis by accident while removing an extra line that was in there while it was still intended for sqlite.
Which is also why the datatypes are a mess, which I really need to fix as this is supposed to run on postgresql and mysql as well.
Anyhow.. it looks like this now stat.executeUpdate(
"CREATE TABLE weerstations ( "+
" stationsnummer VARCHAR(5) NOT NULL,"+
" voortzetting VARCHAR(5),"+
" naam VARCHAR(255) NOT NULL,"+
" positie VARCHAR(255) NOT NULL,"+
" terreinhoogte DOUBLE(2, 1), "+
" karakteristiek VARCHAR(255) NOT NULL,"+
" grondsoort VARCHAR(255) NOT NULL,"+
" barometer DOUBLE(3, 1),"+
" windmeetmast INT(2)" +
);Which looks correct to me, but it's throwing
java.sql.SQLSyntaxErrorException: Syntax error: Encountered "(" at line 1, column 194.[edit]:
Thinking "I need this working" more than "I need this working properly" I also attempted stat.executeUpdate(
"CREATE TABLE weerstations ( "+
" stationsnummer VARCHAR NOT NULL,"+
" voortzetting VARCHAR,"+
" naam VARCHAR NOT NULL,"+
" positie VARCHAR NOT NULL,"+
" terreinhoogte DOUBLE(2, 1), "+
" karakteristiek VARCHAR NOT NULL,"+
" grondsoort VARCHAR NOT NULL,"+
" barometer DOUBLE(3, 1),"+
" windmeetmast INT" +
);Which gets me a java.sql.SQLSyntaxErrorException: Syntax error: Encountered "NOT" at line 1, column 56.Edited by: Axeia on May 21, 2009 12:28 PM -
Syntax error or access violation...
I have recently purchased a .com and webhosting through the company hostgator.com , I am currently trying to integrate a java application thru this .com and the databases they provide me to use
Anyway, here is the code I have
====
import java.sql.*;
public class mysql_connector
* @param args
public static void main(String[] args)
Connection conn = null;
try
String userName = "******";
String password = "*******";
String url = "jdbc:mysql://bkardi.com:3306/******";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
catch (Exception e)
System.err.println ("Cannot connect to database server");
System.out.println(e);
finally
if (conn != null)
try
conn.close ();
System.out.println ("Database connection terminated");
catch (Exception e) { /* ignore close errors */ }
}and here is the error I get
Cannot connect to database serverjava.sql.SQLException: Syntax error or access violation message from server: "Access denied for user 'buk110_kardi'@'24.115.97.153' to database 'buk110_java'"
Any ideas, suggestions?You need to verify your parameters. The error message is telling you:
"Access denied for user 'buk110_kardi'@'24.115.97.153' to database 'buk110_java"
So you have some sort of a login issue, either username/password and/or access to the database specified. If all of these are correct then you need to talk to the web host and make sure that they have set up your DB correctly. -
Syntax error while writing a select query.
Hi all,
I have a requirement where I have to pick a value if the text for that value is
MYCARu2019S Lovliest Car.
And so I wrote a query that
SELECT RUECK INTO XRUECK FROM AFVC WHERE ltxa1 = ' MYCARu2019S Lovliest Car'.
ENDSELECT.
But it gives me a syntax error saying
u201CLiterals taking up more than one line not permittedu201D.
Can some one tell me what is wrong. I need to select RUECK value from AFVC table if
ltxa1 value is ' MYCARu2019S Lovliest Car'.
Kindly help what is going wrong...
Regards,
Jessica SamHi,
Narendran is right use two single quotes.
also careful wile comparing string. i think as you write ltxa1 value is ' MYCARu2019S Lovliest Car'.
so while comparing you must not use space just before staring use the following
SELECT rueck INTO xrueck FROM afvc WHERE ltxa1 = 'MYCAR''S Lovliest Car'. " Not use Space before M
ENDSELECT.
Hope will help you.
Kind Regards,
Faisal -
Select-options in SELECT query - syntax error
Hi all,
I get the error below when I try to use the select options in a SELECT query . Please help me.
"The IN operator with "SO_AWART" is followed neither by an internal
table nor by a value list."
The code i have used(Logical database PNP is used):
TABLES: pernr,
catsdb.
INCLUDE ztime_cwtr_top. " global Data
INCLUDE ztime_cwtr_f01.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS SO_AWART FOR CATSDB-AWART.
PARAMETERS P_THRES TYPE I.
SELECTION-SCREEN END OF BLOCK B1.
Get data from CATSDB table. Workdates within the date interval are considered.
SELECT pernr workdate awart catsquantity beguz enduz status
FROM catsdb
INTO TABLE it_catsdb
WHERE pernr = pernr-pernr AND
workdate GE pn-begda AND
workdate LE pn-endda AND
status IN ('20', '30') AND
awart IN so_awart .
awart IN ('1100', '1137', '1138', '1139', '1140',
'1147', '1148', '1149', '1157', '2003' ).
when I give the values directly i do not get any syntax error, but when I use select options in the where condition I get the syntax error.
I have tried different options like using only the select-options in the where condition.
Thanks in advance.....
MadhuSolved.
Code with syntax error:
include z...top .
include z...fo1.
select-options: xxxxxxx
Code with no syntax error:
select-options: xxxxxxx
include z...top .
include z...fo1.
Thanks for all your help,
Madhu
Maybe you are looking for
-
Adobe Reader not working after update to version XI
I have had Adbobe Reader installed on my PC for ages and have been using this to view my PDF files without any issues. However, Adobe Reader updated automatically to version XI a few days ago. Since then, I have been completely unable to open Adobe R
-
Cannot locate 'upgrade catalog' tab in LR4.2 file pulldown
I'm trying to bring PSE8 catalogs in to LR4.2 but I do not see the 'upgrade catalog' command in the file pulldown as shown in the LR4 tutorials. Thanks in advance, Chris
-
I am unable to send ringtone from itunes
Hi, I have installed ringtone maker in my iphone 4s, from that created a ringtone. The same was opened with itunes installed in my laptop. But once i tried to save the ringtone to my laptop, itunes will stop working and close down. I reinstalled the
-
HT1689 Going to Italy and London. What converters do I need to plug into to recharge?
Going to be in Italy and London. What converters do I need to plug iphone into to re-charge? I know there are different ones for different countries.
-
Ejected my self out of my Skype Manager group
hello. i forgot my skype manager admin user password and requested a new one. in that process by some reason one of the skype members saw a notification that my admin user has left the group. and when i now login to my skype manager account its empth