i had this exception while trying to insert new records in MSSQL 2000 via
JDBC:
DDL for SQL 2000 (generated from SQL EM):
CREATE TABLE [dbo].[tblQuotes] (
[quoteDetailId] [int] IDENTITY (1, 1) NOT NULL ,
[quoteId] [int] NOT NULL ,
[roomDescription] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[material_desc] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[serviceDescription] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[sqFeet] [int] NULL ,
[priceSqFeet] [float] NULL ,
[trackingId] [int] NULL
) ON [PRIMARY]
GO
--------
And here is my Java code to get an object from Vector container and display
its properties:
String UPDATE_QUOTE = "INSERT INTO tblQuotes (material_desc,
roomDescription, sqFeet, priceSqFeet, quoteId, trackingId) VALUES ('?', '?',
?, ?, ?, ?);";
...
pst = con.prepareStatement(UPDATE_QUOTE);
Quote oneQuote = (Quote)finalQuote.elementAt(i);
int integerSqFeet = Integer.parseInt(oneQuote.getSqFeet());
float floatPriceSqFeet =
Float.parseFloat(oneQuote.getPriceSqFeet());
int integerQuoteId =
Integer.parseInt(oneQuote.getQuoteId());
int integerTrackingId = Integer.parseInt(trackingid);
pst.setString(1, oneQuote.getMaterialDescription());
pst.setString(2, oneQuote.getRoomDescription());
pst.setInt(3, integerSqFeet);
pst.setFloat(4, floatPriceSqFeet);
pst.setInt(5, integerQuoteId);
pst.setInt(6, integerTrackingId);
pst.execute();
pst.close();
-------------------------------------------
java.sql.SQLException: Error converting data type nvarchar to float.
Severity 16, State 5, Procedure 'DEV7 null', Line 8
at
weblogic.jdbcbase.mssqlserver4.TdsStatement.processWarning(TdsStatement.java
:1240)
at
weblogic.jdbcbase.mssqlserver4.TdsStatement.parseMsWarning(TdsStatement.java
:1151)
at
weblogic.jdbcbase.mssqlserver4.TdsStatement.getMoreResults(TdsStatement.java
:814)
at
weblogic.jdbcbase.mssqlserver4.TdsStatement.execute(TdsStatement.java:211)
at
weblogic.jdbcbase.mssqlserver4.TdsStatement.execute(TdsStatement.java:1554)
at com.ralphsflooring.at.Quotes.UpdateCustomerQuotes(Quotes.java:157)
at com.ralphsflooring.at.test.TestVector.main(TestVector.java:23)
The SQL statement executes fine in the query analyzer but what do i do
here - all fields seem to be mapped correctly ? Thanks for your help.
m.
String UPDATE_QUOTE =
"INSERT INTO tblQuotes (material_desc, roomDescription, sqFeet, priceSqFeet, quoteId, trackingId)
VALUES (?, ?, ?, ?, ?, ?)";
Also note that there should not be any semicolon at the end.
Joe
"Joseph Weinstein" <j...@bea.com> wrote in message
news:3D347ACD...@bea.com...
malkovitz wrote:
> Thanks a lot - it worked
coolness. glad to help.
Joe