473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

jdbc to odbc

153 100+
Hi all,

After an hour of searching i have decided to surrender and ask!

Expand|Select|Wrap|Line Numbers
  1. s.execute("INSERT INTO customers values(?," +name + "','" + address + "','" + email + "','" + phone + "','" + purchase + "')")
is saying [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect

This is because of the first value ?. I have an auto increment table in microsoft access but if I don't enter ? as the value for the auto increment column i get a mismatch error.

Any one know the proper syntax for my problem(how to let access add the auto increment data when working via java)?

Regards

Brendan
Jun 17 '09 #1
10 3388
JosAH
11,448 Expert 8TB
@brendanmcdonagh
I don't know if it matters much but you're missing a single tick (') before the name field. (it's better to use PreparedStatements for this purpose for a couple of reasons).

kind regards,

Jos
Jun 17 '09 #2
dmjpro
2,476 2GB
@brendanmcdonagh
Expand|Select|Wrap|Line Numbers
  1. String query = "insert into TABLE(col1....coln) values(val1....valn)";
  2. s.execute(query);
  3.  
Jun 17 '09 #3
brendanmcdonagh
153 100+
Expand|Select|Wrap|Line Numbers
  1. String query = "INSERT INTO customers values(?,'" +name + "','" + address + "','" + email + "','" + phone + "','" + purchase + "')"; 
  2. s.execute(query);
new code - same error message!

Regards

Brendan
Jun 17 '09 #4
dmjpro
2,476 2GB
@brendanmcdonagh
Why are you putting ? mark?
Are you trying to put the value automatically?
Did you see my post ... simply mention the column name and put the values accordingly and no need to put the put auto increment value.
Jun 17 '09 #5
r035198x
13,262 8TB
@dmjpro
Because that is the correct way of doing it.
Read the PreparedStatement API for details.
Jun 17 '09 #6
JosAH
11,448 Expert 8TB
@r035198x
That is not what the OP attempted to use it for; the first column of that table is an auto-increment column and the OP was trying to express ? as 'I don't know what to put here'; Dmjpro is probably right here: explicitly mention all column names for which values are supplied.

kind regards,

Jos
Jun 17 '09 #7
brendanmcdonagh
153 100+
Expand|Select|Wrap|Line Numbers
  1. String query = "INSERT INTO customers(id, customerName, customerAddress, customerEmail, customerNumber, customerPurchase/s) values('" +name + "','" + address + "','" + email + "','" + phone + "','" + purchase + "')";
This is now showing a sql syntax error when executed??
Jun 17 '09 #8
JosAH
11,448 Expert 8TB
@brendanmcdonagh
I can see a /s in that string; better print out that string before you feed it to your sql engine. For your next post: it would be convenient if we know too what the exact error message was.

kind regards,

Jos
Jun 17 '09 #9
brendanmcdonagh
153 100+
and the answer is......

Expand|Select|Wrap|Line Numbers
  1. s.execute("INSERT INTO customers(customerName, customerAddress, customerEmail, customerNumber, customerPurchase) values('" +name + "','" + address + "','" + email + "','" + phone + "','" + purchase + "')");
p.s any one know how to close a frame rather than just setVisible(false)

I have frame1 opening frame2(I want to close frame1 here) and then frame2 is opening a new instance of frame1(i want to close frame2 here)

Any ideas?
Jun 17 '09 #10
JosAH
11,448 Expert 8TB
@brendanmcdonagh
So it was that misplaced / character? You can get rid of a JFrame by calling the dispose() method inherited from the Window class.

kind regards,

Jos
Jun 18 '09 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: mp | last post by:
I just upgraded to Tomcat 4.1.29 and I am receiving the following error when I connect via ODBC to an oracle database: java.lang.ClassNotFoundException: Security Violation, attempt to use...
4
by: Riccardo | last post by:
Hi, This jsp code doesn't run. Why ? ----------------------------------------------------------- <%@ page import="java.sql.*" %> <%! String Query(String SQL, String DSN) {
1
by: jdavis999x | last post by:
I have spent a good deal of time looking for how to connect an applet to a remote database (MS Access) using JDBC, as yet I have found no solid solution!! According to some books I have read the...
9
by: Albretch | last post by:
.. I am trying to create a database in a MS Access DB via JDBC drivers. I have tried both sun.jdbc.odbc.JdbcOdbcDriver and ids.sql.IDSDriver From some reason both drivers Exceptions tell me...
4
by: Izak van Langevelde | last post by:
Shocks. Today I came to learn that Suns jdbc-odbc bridge driver isn't meant for serious purposes; it's experimental. I already knew it isn't thread safe, but didn't think of this as problematic for...
5
by: Dino Nardini | last post by:
Hey folks, I'm currently evaluating an upgrade path from our current ColdFusion 5 / PostgreSQL setup to ColdFusion MX / PostgreSQL. In the current setup, we're using the Merant ODBC driver for...
1
by: BARTKO, Zoltán | last post by:
Hello folks, I have installed PgSQL8 beta4 via pginstaller to WinXP. I must tell you I am more familiar with Linux, so maybe my problem is trivial to solve: I made myself a table with...
3
by: stmfc | last post by:
"The designers of ODBC aimed to make it independent of programming languages, database systems, and operating systems." (http://en.wikipedia.org/wiki/ODBC) 1- Does it mean that all (or most)...
1
by: wnaveenkumar | last post by:
package com.trewport.orderprocess.action; import java.io.*; import java.sql.*; import java.util.*; import java.util.Date; import java.lang.Object; import javax.servlet.*; import...
4
by: robtyketto | last post by:
Greetings, I'm a newbie to Java and I cant quite get my head around why it seems most integers appears to be formatted as strings and then later have to be parsed. The code below, passes in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.