Go Back   Trackpads Community > General Discussions > Computer and Technology > Web Design

Web Design Forums and discussions on webdesign

Web Design

Reply
 
LinkBack Thread Tools
Old 06-15-2004, 14:07   #1 (permalink)
Nathan Sokalski
Civilians

 
Default Using the DECIMAL type in a CREATE TABLE statement

I am writing a Java program which involves creating a table in a Microsoft
Access database. I am having trouble creating the field which is of type
DECIMAL. I recieve the following error from Java:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax
error in field definition.

I tried entering the field as each of the following:

CREATE TABLE Employee(Salary DECIMAL)
CREATE TABLE Employee(Salary DECIMAL(10,2))
CREATE TABLE Employee(Salary Decimal)
CREATE TABLE Employee(Salary Decimal(10,2))

If anyone has any knowledge as to what the correct syntax is, I would
appreciate your help. I would also like to know of any reference sites that
show the syntax for the types when using CREATE TABLE. Thank You.
--
Nathan Sokalski
njsokalski@hotmail.com


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Trackpads Information
Click to Visit
Old 06-15-2004, 14:08   #2 (permalink)
Antoine
Civilians

 
Default Re: Using the DECIMAL type in a CREATE TABLE statement

Seems to be a problem of compatibility driver. Java is not fiting very well
with odbc.
Look at the specification of the driver you use (level 1, 2 or 3 ?) to see
if it can do this (see search engines).
Also try the same query within access, to see if it's working (may be a pb
in the query itself or a pb of creating this table in access, without odbc
involved).
more over, I don't use decimal type in access. never done. I don't trust it.
may be use another type ?
if you create the table "on the fly" by program : either, you use a
pre-build table that you don't delete (just suppress the records), or you
use the real type (as a temporary table, it may fit).
hope this help.
Antoine



"Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
news:eKL6NQ#AEHA.220@TK2MSFTNGP09.phx.gbl...
> I am writing a Java program which involves creating a table in a Microsoft
> Access database. I am having trouble creating the field which is of type
> DECIMAL. I recieve the following error from Java:
>
> java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax
> error in field definition.
>
> I tried entering the field as each of the following:
>
> CREATE TABLE Employee(Salary DECIMAL)
> CREATE TABLE Employee(Salary DECIMAL(10,2))
> CREATE TABLE Employee(Salary Decimal)
> CREATE TABLE Employee(Salary Decimal(10,2))
>
> If anyone has any knowledge as to what the correct syntax is, I would
> appreciate your help. I would also like to know of any reference sites

that
> show the syntax for the types when using CREATE TABLE. Thank You.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
>
>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-15-2004, 14:08   #3 (permalink)
Lars-Inge Tønnessen
Civilians

 
Default Re: Using the DECIMAL type in a CREATE TABLE statement

Sorry, I don't have Access. But this works with the MS SQL Server and the MS
JDBC driver.

Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver");
Connection conn =
DriverManager.getConnection("jdbc:microsoft:sqlser ver://localhost:1433;User=
user;Password=password");

String query = "create table SUPPLIES "+
"(SUP_ID INTEGER, "+
"SUP_NAME VARCHAR(40), "+
"DOUB DECIMAL(12,4))";

Statement sts = conn.createStatement();
sts.executeUpdate( query );



Lars-Inge Tønnessen
www.larsinge.com


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-15-2004, 14:08   #4 (permalink)
Nathan Sokalski
Civilians

 
Default Re: Using the DECIMAL type in a CREATE TABLE statement

I'm not suprised about that, because Access doesn't have EXACTLY the same
syntax as SQL; Microsoft, as always, decided to make their own adjustments.
However, it is supposedly close enough that most of the stuff can still be
done. And since I am forced to use Access, I need to figure out how to do it
with Access. But all information could end up being of use at some time or
another, so thanks anyway.
--
Nathan Sokalski
njsokalski@hotmail.com
"Lars-Inge Tønnessen" <http://emailme.larsinge.com> wrote in message
news:Oq681KABEHA.1700@TK2MSFTNGP12.phx.gbl...
> Sorry, I don't have Access. But this works with the MS SQL Server and the

MS
> JDBC driver.
>
> Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver");
> Connection conn =
>

DriverManager.getConnection("jdbc:microsoft:sqlser ver://localhost:1433;User=
> user;Password=password");
>
> String query = "create table SUPPLIES "+
> "(SUP_ID INTEGER, "+
> "SUP_NAME VARCHAR(40), "+
> "DOUB DECIMAL(12,4))";
>
> Statement sts = conn.createStatement();
> sts.executeUpdate( query );
>
>
>
> Lars-Inge Tønnessen
> www.larsinge.com
>
>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-15-2004, 14:08   #5 (permalink)
Lars-Inge Tønnessen
Civilians

 
Default Re: Using the DECIMAL type in a CREATE TABLE statement

I found these, maybe they could be of any help:

http://msdn.microsoft.com/library/de...rDatatypes.asp

http://msdn.microsoft.com/library/de...softAccess.asp

Maybe it's the "Currency" you want?
http://members.lycos.co.uk/zhanshan2...createsql.html

http://msdn.microsoft.com/library/de...plhet_4nn2.asp



(The free MSDE or the MS SQL Server Personal edition is the way to go
=) )

Lars-Inge Tønnessen
www.larsinge.com


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-15-2004, 14:08   #6 (permalink)
Antoine
Civilians

 
Default Re: Using the DECIMAL type in a CREATE TABLE statement

it may be a question of syntax, or a question of using odbc driver with
java, or more precisely, using java and access together ("they don't like
much each other").
I have developped softwares with access since 97. I now work with java.
I will rewrite, may be, some of them with java (new way of doing the same
things... with web design and full object programming).
In my search to prepare this, I wondered if I could keep Access as database
(many tables yet working, SQL queries yet written, ... and that won't
change).
It seems that it is very risky to use some odbc driver with Java, and JDBC
drivers (safe and robust with java) for access are expensive (see web search
on this subject).
For my projects, I will use MySQL, since it is know full RDBMS (with
external key feature)...

if you have to work with Access, be very aware of this kind of pb you may
find, involving compatibility between ODBC and JDBC....
Antoine











"Lars-Inge Tønnessen" <http://emailme.larsinge.com> wrote in message
news:ORr23HEBEHA.444@TK2MSFTNGP11.phx.gbl...
> I found these, maybe they could be of any help:
>
>

http://msdn.microsoft.com/library/de...rDatatypes.asp
>
>

http://msdn.microsoft.com/library/de...softAccess.asp
>
> Maybe it's the "Currency" you want?
> http://members.lycos.co.uk/zhanshan2...createsql.html
>
>

http://msdn.microsoft.com/library/de...plhet_4nn2.asp
>
>
>
> (The free MSDE or the MS SQL Server Personal edition is the way to go
> =) )
>
> Lars-Inge Tønnessen
> www.larsinge.com
>
>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Pivot Table Using Code S Jackson Microsoft Applications 8 09-01-2005 16:00
How do I create links from Table of Contents in PowerPoint? Seeker Microsoft Applications 8 01-03-2005 00:00
how to create table like columns with css Steven Web Design 7 11-29-2004 19:00
question: repeatable way to create a pivot table alex Microsoft Applications 1 11-17-2004 13:00
How to create a report from a data table mr_steve Microsoft Applications 1 06-16-2004 02:06


Community Information
Options
Quick Options
Trackpads Non-Commercial Ad
Copyright Information Click to Visit
Time
Server Time
All times are GMT -4. The time now is 10:03.
Copyright
Copyright Information
The header is based off of work by Vipixel.com and modified by this site. Trackpads and the Trackpads Logo are both Registered Trademarks of Jason Edwards and cannot be used without prior written permission.  The only exception is as a link back to this site. Trackpads is a private website run by a small legion of volunteers, 3 dogs, 12.5 cats and an army of small, super smart, bio-engineered mice with pointy hats and tutu's. Search Engine Friendly URLs by vBSEO 3.2.0 RC7
Archive Links
Archive Links
Page generated in 0.87174 seconds with 19 queries