Dear Community a pleasure to greet you, I am reading several HoldinRegister type registers for that I am using easymodbus in total will be 150 registers that must be read and saved each time a Coil type register changes from 0 to 1, the reading of these registers is done as follows: - public static void main(String[] args) throws Exception
-
{
-
ModbusClient modbusClient = new ModbusClient();
-
modbusClient.Connect("127.0.0.1", 502);
-
int[] inputRegisters = modbusClient.ReadHoldingRegisters(0, 149);
-
for (int i=0; i < inputRegisters.length; i++)
-
System.out.println("Holding Register #"+i+": "+inputRegisters[i]);
-
}
The values of the registers are updated only when the Coil changes its value, then save those registers in the database, I think this is better because if they would be updating all the time it would consume too many resources.
My question now is how can I do to save that amount of data at the same time, searching the net I found an example using FOR but I don't understand very well how to integrate it since I can't make it work. - String SQL = "INSERT INTO ingredients(date,regnumb,regval)"
-
+ "values (?,?,?)";
-
-
mensaje="data inserted correctly";
-
try{
-
PreparedStatement sqls = (PreparedStatement) conn.prepareStatement(SQL);
-
-
int rows =4;
-
-
-
for(int i = 0; i
-
sqls.setString(1, date);
-
sqls.setString(2, regnumb);
-
sqls.setString(5, regval);
-
sqls.addBatch();
-
} sqls.executeBatch();
thank you very much for your attention
1 10858 dev7060 639
Recognized Expert Contributor
I haven't worked with Modbus communication or its libraries. I can provide generic advice. Proceed if it sounds useful to you.
The values of the registers are updated only when the Coil changes its value, then save those registers in the database
How does the 'Coil' change its value? If there's an event listener provided in the library, the code to update the database can be put in the function. - String SQL = "INSERT INTO ingredients(date,regnumb,regval)"
-
+ "values (?,?,?)";
-
-
mensaje="data inserted correctly";
-
try{
-
PreparedStatement sqls = (PreparedStatement) conn.prepareStatement(SQL);
-
-
int rows =4;
-
-
-
for(int i = 0; i
-
sqls.setString(1, date);
-
sqls.setString(2, regnumb);
-
sqls.setString(5, regval);
-
sqls.addBatch();
-
} sqls.executeBatch();
I see syntax errors.
My question now is how can I do to save that amount of data at the same time, searching the net I found an example using FOR but I don't understand very well how to integrate it since I can't make it work.
What do you want to 'integrate' with what? What isn't working? What errors do you see? You may want to mention the specific database schema or columns and what updates are to be made and where.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Frank Pryor |
last post by:
Hello,
I'd appreciate suggestions as I hash out my idea. Perhaps I'm going about
this the wrong way.
I have users using a third party windows application. They can export data
from this application directly to a text file (CSV). So far as I know,
there is no way to make this application talk directly to the MySQL server.
We're...
|
by: Ian Macey |
last post by:
I am wanting to Insert multiple records into a table, and although I have some working code I feel that there must be a better way. The purpose of the code is to do a directory listing of a sub-directory and for each file listed insert a record into a temporary table.
Can anyone help?
My code is as follows....
SQL Stored Procedure...
|
by: Tom Gao |
last post by:
I have a problem. The project that I'm working on requires me to duplicate
records. As in a series of records are entered into the system the user then
click on a button to make these as 'Templates' so that they would not have
to re-enter alot of the information. So from a db perspective I would have
to re-insert these records into the...
|
by: Chris |
last post by:
i am looking for the fastest way to insert several 1000
trx int oracle. is there a faster way, then using a
DataAdapter? is there a possibilty to execute a bulk load
(or batchwise insert with transactionsize)? any
suggestions? thanks a lot!!
chris
|
by: xoozlez |
last post by:
Hi there,
How do I insert new records from a dbo table to another table?
This is what I have:
1 dbo_company
1 Member (table)
I made a query in dbo_company with the criteria I only want to retrieve out new records from "ceo_email" and "contact_email" column after e.g 25.July.07
| |
by: chumlyumly |
last post by:
Hello scripters -
OS: Mac OSX
Language: PHP w/ MySQL database
I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The tables are all linked with the field 'member_id', which is an auto-increment field in the parent table ('members').
I've been able to input multiple...
|
by: veer |
last post by:
can any one help by providing the method inserting the records in excel file
because i created it all it works fine but i have no idea about how to insert new records in the existing excel file.
e.g
my excel sheet has filled first 20 rows and then
i want to insert the new records in the excel sheet starts from 21st row
is any idea about...
|
by: ndhvu |
last post by:
Tables: Buy_Header and Buy_Detail.
- Buy_Header: info. of each buy (buy_id(PK, auto number), date, shop, bought_by, ...)
- Buy_Detail: info. of each item from each buy (buy_detail_id(PK, auto number), buy_id, item_name, price, quantity,...)
Target:
- Make a main-form of table with sub-form of table to insert/update records for both...
|
by: Blake Rice |
last post by:
Hi everyone! This is my first time posting here, so here goes.
THE SITUATION:
I have a form that has a start date, end date, project number, and total volume. These values are pulled from another form. Then depending on the difference between the start and end dates, that number of text boxes have their visibility set to TRUE and are displayed...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |