473,394 Members | 1,700 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,394 software developers and data experts.

sql: problem with matching data types

Hi. I want to insert data to ms access but I think I have a prob with data types.

This is my code.
[code]

savebutton.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con= DriverManager.getConnection(url);

String sqlStatement = "insert into PatientDB(PatientID,Name,Surname,Phoneno,Dateofbir th,Complaint) values(numberinput.getInteger(),nameinput.getText( ),surnameinput.getText(),phoneinput.getInteger(),d ateofbirthinput.getInteger(),tet.getText())";
PreparedStatement pstmt = con.prepareStatement(sqlStatement);
pstmt.executeUpdate();


con.close();


}

catch(ClassNotFoundException ex)
{}


catch(SQLException ex)
{
ex.printStackTrace();
}

}
});
[\code]





[error]

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Undefined function 'numberinput.getInteger' in expression.
[\error]
Sep 18 '07 #1
1 1566
Scott Price
1,384 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO PatientDB ([PatientID],[Name],[Surname],[Phoneno],[Dateofbirth],[Complaint]) VALUES ( numberinput.getInteger(),nameinput.getText( ),surnameinput.getText(),phoneinput.getInteger(),d ateofbirthinput.getInteger(),tet.getText())";
It's not a data type problem, just a syntax problem in the Insert Into query, making a reference to a variable, etc with closing ()'s makes Access look for a function in a vba code module. I'm not an expert on the way your refer to controls or variables in Java, but it looks like that is what you are trying to do.

Here is an example from a test db of mine that shows correct syntax for vba, you'll have to explore a little more on the Java side of things to find out how to make those references in Java, take a look at our Java forum for more specific help there:

Expand|Select|Wrap|Line Numbers
  1. MySQL = "INSERT INTO tblTimeDiff ([TransID], [TimeDiff]) VALUES ('" & Temp1 & "','" & Temp2 & "');"
It takes the variable Temp1 and concatenates it's value into the TransID field, and the Temp2 variable likewise into the TimeDiff field.

Regards,
Scott
Sep 18 '07 #2

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

Similar topics

26
by: David W. Fenton | last post by:
A client is panicking about their large Access application, which has been running smoothly with 100s of thousands of records for quite some time. They have a big project in the next year that will...
4
by: BerkshireGuy | last post by:
Our IT department wants to place our Access 2000 tables on an SQL server due to the fact the tables are quite large. With that said, can we still use the Access queries or do we have to do...
1
by: Martin Widmer | last post by:
Hi guys I am wondering what is a proper way to persistently store objects into SQL-Server. I see four possible ways: 1.) Serialize to XML and then store the XML in the SQL server 2.) Write a...
12
by: Bill Bob | last post by:
I am going mad with this Query. I need to join 3 Tables. Their Formats are Vouchers NOT NULL , NOT NULL , NULL , NOT NULL , (255) CONSTRAINT PRIMARY KEY CLUSTERED
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
0
NeoPa
by: NeoPa | last post by:
Introduction Joins, in SQL, are a way of linking Recordsets together. They involve restricting which data is returned in the output Recordset. When no join is specified but two Recordsets are,...
0
by: Medhatithi | last post by:
Hi, I have been in several ways benefiited from this site. I would like to share some sql tuning techniques(simple, but effective) with you all. SQL Tuning Tips Oracle Tips Session #6 ...
0
by: Mikhail Teterin | last post by:
Daniel Pitts wrote: Uhm, why? I'm quite sure, we are not alone here with the need to have an object for every row return by an SQL-query... Well, here is what I cooked up: ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.