HI again folks. I spent my weekend coding a function to do statistical analysis on a time series and to my amazement it works without a hitch. I even verified my results were correct with excel. I am having an issue passing these values to my database table. All JDBC drivers are loaded correctly as I can "hard-code" a String and pass run executeUpdate() and it works. Of course I cannot hard-code my entire project. -
//update masterTable
-
String sqlRecord ="Update MasterTable set [Slope] = "+beta1+" WHERE Abbreviation = "+company;
-
try
-
{
-
db_statement.executeUpdate(sqlRecord);
-
System.out.println ("-= record updated =-");
-
}catch (Exception excep) {
-
System.out.println ("Unable to update record: n" + excep);
-
System.exit(0);
-
}
-
The error I am getting is:
"Unable to update record: njava.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1."
Thoughts, advice, suggestions??
As I stated earlier if i do something like: - String sqlRecord("Update Mastertable set [slope] = '-0.3234234243645' WHERE Abbreviation = 'AAPL'");
-
it works.
6 1883
HI again folks. I spent my weekend coding a function to do statistical analysis on a time series and to my amazement it works without a hitch. I even verified my results were correct with excel. I am having an issue passing these values to my database table. All JDBC drivers are loaded correctly as I can "hard-code" a String and pass run executeUpdate() and it works. Of course I cannot hard-code my entire project. -
//update masterTable
-
String sqlRecord ="Update MasterTable set [Slope] = "+beta1+" WHERE Abbreviation = "+company;
-
try
-
{
-
db_statement.executeUpdate(sqlRecord);
-
System.out.println ("-= record updated =-");
-
}catch (Exception excep) {
-
System.out.println ("Unable to update record: n" + excep);
-
System.exit(0);
-
}
-
The error I am getting is:
"Unable to update record: njava.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1."
Thoughts, advice, suggestions??
As I stated earlier if i do something like: - String sqlRecord("Update Mastertable set [slope] = '-0.3234234243645' WHERE Abbreviation = 'AAPL'");
-
it works.
You already solved it buddy :-)
Anyway change this..... -
String sqlRecord ="Update MasterTable set [Slope] = "+beta1+" WHERE Abbreviation = "+company;
-
//you had this
-
String sqlRecord ="Update MasterTable set [Slope] = '"+beta1+"' WHERE Abbreviation = "+company;
-
//the change is "+beta1+" to '"+beta1+"'
-
Enjoy the code.
Debasis Jana
You already solved it buddy :-)
Anyway change this..... -
String sqlRecord ="Update MasterTable set [Slope] = "+beta1+" WHERE Abbreviation = "+company;
-
//you had this
-
String sqlRecord ="Update MasterTable set [Slope] = '"+beta1+"' WHERE Abbreviation = "+company;
-
//the change is "+beta1+" to '"+beta1+"'
-
Enjoy the code.
Debasis Jana
Gives me the same error, this is driving me nuts. I have looked at it and changed it around in every logical sense I can think of and still get the same error. I have even double checked my ACcess database to make sure there is room for a number of that size, etc...
Gives me the same error, this is driving me nuts. I have looked at it and changed it around in every logical sense I can think of and still get the same error. I have even double checked my ACcess database to make sure there is room for a number of that size, etc...
Hi,
Try to print you query ... and see what values of beta and company are replacing in your query.
You already solved it buddy :-)
Anyway change this..... -
String sqlRecord ="Update MasterTable set [Slope] = "+beta1+" WHERE Abbreviation = "+company;
-
//you had this
-
String sqlRecord ="Update MasterTable set [Slope] = '"+beta1+"' WHERE Abbreviation = "+company;
-
//the change is "+beta1+" to '"+beta1+"'
-
Enjoy the code.
Debasis Jana
Sorry those two fields are Text.
So you need to do one more change here. -
String sqlRecord ="Update MasterTable set [Slope] = '"+beta1+"' WHERE Abbreviation = '"+company+"'";
-
Now have a try with this :-)
Good Luck !
Debasis Jana
ah that worked, thank you kindly again:)
Now I need to figure out why it updated my first company, but not the second one. Ran through the for loop fine, said it updated but when i checked Access only 1 of the 2 companies was updated.
EDIT: seem to have figured it out, just called a closeconnection function and it worked:)
ah that worked, thank you kindly again:)
Now I need to figure out why it updated my first company, but not the second one. Ran through the for loop fine, said it updated but when i checked Access only 1 of the 2 companies was updated.
EDIT: seem to have figured it out, just called a closeconnection function and it worked:)
I already told you that you solved it but you can't do that in Java Coding. -
String sqlRecord("Update Mastertable set [slope] = '-0.3234234243645' WHERE Abbreviation = 'AAPL'");
-
If your table fields are text then you need to have semi-colons.
Debasis Jana
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jimserac |
last post by:
I had previously posted this in an Access forum
with negative results so will try here.
Although this question specifies an Access database,
I also wish to accomplish this with a large MS SQL...
|
by: Niyazi |
last post by:
Hi,
I have not understand the problem. Before all the coding with few
application everything worked perfectly. Now I am developing Cheque Writing
application and when the cheque is clear the...
|
by: Michael Eisner |
last post by:
I have an MS Access 8.0 (Office97) program that has a form called
FO-008 that I need to replace on several users computers in different
locations without me being there doing it manually.
I'm...
|
by: PAUL |
last post by:
Hello,
I have 2 tables with a relationship set up in the dataset with vb
..net. I add a new record to the parent table then edit an existing child
record to have the new parent ID. However when I...
|
by: lmnorms1 |
last post by:
Hello,
I am trying to update an access database record date field that matches
a specific date. The code is not working. Anyone have any advice?
Here is the code:
Dim gConnString As String =...
|
by: Stephen D Cook |
last post by:
I am trying to write to an ACCESS database. I have full permission and
Read/Write capability set for the database and folder. But when I get
to MoveLast or Update, I get an error of the database is...
|
by: Yew12 |
last post by:
I have been trying to update the details in a access database but, all I get is a white screen and all the errors I have built-in give me no help at all.
All help is greatly appreciated.
...
|
by: Michel Esber |
last post by:
Hi all,
DB2 V8 LUW FP 15
There is a table T (ID varchar (24), ABC timestamp). ID is PK.
Our application needs to frequently update T with a new value for ABC.
update T set ABC=? where ID...
|
by: pereges |
last post by:
Hello, I'm trying to build a database driven website for a library
management system. The database is stored on a remote server which all
of my team mates can access. I've installed MySQL, PHP and...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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,...
|
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...
|
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: 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,...
| |