Is there a C# DataTable equivalent in Java?
Java DataTable is available on Maven.
Create a new DocumentBuilder object on your Document. Start a new table using DocumentBuilder. If we want to insert the names of each of the columns from our DataTable as a header row then iterate through each data column and write the column names into a row in the table. Iterate through each DataRow in the DataTable.
A data table contains relational data that can be referenced as follows: from Java code through wrappers as Java arrays. through OpenL Tablets run-time API as a field of the Rules class instance.
After you create a DataTable and define its structure using columns and constraints, you can add new rows of data to the table. To add a new row, declare a new variable as type DataRow. A new DataRow object is returned when you call the NewRow method.
A similar question that has been asked recently. ResultSet certainly is not a direct equivalent as it only works with an active connection to the database while a DataTable can be used "offline".
From personal experience I would say there is no direct equivalent in Java (haven't tried javax.sql.rowset.WebRowSet
, though). You either go with plain SQL and java.sql.ResultSet
is your friend. Or you use some ORM tool like Hibernate, Cayenne, Toplink to name a few. Or you build your own (not that I encourage this, but I think on more than one project that has been done successfully).
Give this framework a try:
Casper Datasets
Its a in-memory dataset library that is generic and also type safe. You can:
Its easy-to-use and doesn't have any significant dependencies. Its also compliant with java.sql.ResultSet, so its possible to integrate this easily into any existing apps that query against relational database
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With