![]() | ![]() | ![]() |
| |||||||
| Forums | Register | Groups | Awards | Arcade | Pets | T-Bucks / T-Store | Invite Your Friends | Blogs | Mark Forums Read |
| Web Design Forums and discussions on webdesign |
Web Design | |||||||||
|
|
|
|
| |||||
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Civilians | 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 |
|
| | #2 (permalink) |
| Civilians | 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 > > |
|
| | #3 (permalink) |
| Civilians | 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 |
|
| | #4 (permalink) |
| Civilians | 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 > > |
|
| | #5 (permalink) |
| Civilians | 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 |
|
| | #6 (permalink) |
| Civilians | 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 > > |
|
![]() |
| Bookmarks |
| Thread Tools | |
| |
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 |
![]() | ![]() | ![]() |