I a new to MongoDb GridFs. I am making an application where I am creating a meeting and uploading files related to the meeting. When I save the entire record, the table must have the meeting id auto generated number and the document id that I receive from the mongodb
return gridFsTemplate.store(inputStream, documentName, "image/jpeg", metaData).getId();
Now, the business require that the file is uploaded asynchronously so that the big file does not hold the page and the user does not have to wait for the upload to complete to submit the page. The problem is, I will not get the document id unless the entire upload is done. But unless I have the id, i cannot save the data with meeting id in the mysql table.
Please suggest an alternative.
replace your code to:-
return (ObjectId)gridFsTemplate.store(inputStream, documentName, "image/jpeg", metaData).getId();
Related
1.DatabaseReference db=FirebaseDatabase.getInstance().getReference("users");
1.Query query = db.orderByKey().equalTo(uid);
2.FirebaseDatabase.getInstance().getReference("users").orderByChild("token").equalTo(toKen)
Does any one of the above two codes written in Java Android Studio send the entire "users" node of Realtime Database to the client Android App or Only the the Fetched Records will be send to the client Android App. It Seems like that it sends the complete "users" node to the client Android App, because my realtime database bill is quite high and customers are low.
It seems you are looking for orderByChild(). To get the child node where the value of uid is equal to passed UID, try this:
DatabaseReference db=FirebaseDatabase.getInstance().getReference("users");
Query query = db.orderByChild("uid").equalTo(uid);
The documentation says,
Method
Usage
orderByChild
Order results by the value of a specified child key or nested child path.
orderByKey
Order results by child keys.
The second query looks fine and should fetch the node where the value of token is equal to the supplied token.
If the download size is higher than you'd expect based on the number of query results, check if you've defined an index on the token property. If no such index exists, Firebase will download all data under users to the client, and perform the sort/filter there. If an index is declared, the ordering/filtering is done on the server.
Question
How do I store entire files in my H2 database and retrieve them using JDBC?
Some Background
I have some text files that I have as templates for various documents that will be generated in my Spring Boot app. Currently, I have my text files stored in my local file system on my PC, but that is not a long term solution. I need to somehow store them in the database and provide the necessary code for the JDBC for the retrieval of the files.
Are there any technologies/libraries out there that would help me with this? If so, please link me to them and provide an example of how to do it in Spring Boot.
Note: It is a new requirement given to me that the text files should be stored in the database, and not the file system.
You have to use a BLOB column in your database table.
CREATE TABLE my_table(ID INT PRIMARY KEY, document BLOB);
BLOB stands for Binary Large Object.
http://www.h2database.com/html/datatypes.html#blob_type
To store it with JdbcTemplate you have to create a ByteArrayInputStream
ByteArrayInputStream inputStream = new ByteArrayInputStream(document);
preparedStatement.setBlob(3, inputStream);
Please find more examples here:
https://www.logicbig.com/tutorials/spring-framework/spring-data-access-with-jdbc/jdbc-template-with-clob-blob.html
I have data structure like this for my android app. That can login and only see their profile. I dont make add content or do saving data to the database. So i created the data manually and the users only read and display the data.
How to make login,refer with username = "71140011" and password = "123456" which is inside real time database and the 71140011 only can see their profile only. thanks
We're using BigQuery to retrieve the full content of a big table. We're using the publicly available publicdata:samples.natality.
Our code follows Google instructions as described in their API doc - java.
We're able to retrieve this table at around 1'300 rows/sec that is amazingly slow. Is there a faster way to retrieve the full result of a query or is this always as fast as it gets ?
The recommended way to retrieve a large amount of data from a BigQuery table is not to use tabledata.list to page through a full table as that example is using. That example is optimized for reading a small number of rows for the results of a query.
Instead, you should run an extract job that exports the entire content of the table to Google Cloud Storage, which you can then download the full content from.
https://cloud.google.com/bigquery/exporting-data-from-bigquery
To download a table fast you can use Google BigQuery Storage Client for Java.
It lets you download the tables into efficient binaries format such as Avro or Arrow.
Using the basic Arrow example in the documentation I manage to download ~1 million rows per second.
I think you can use it to download a query result by writing the result into a temporary table.
The code to get the temporary table of the result looks like this:
public static TableId getTemporaryTable(String query) throws InterruptedException{
QueryJobConfiguration queryConfig =
QueryJobConfiguration.newBuilder(query)
.setUseLegacySql(false)
.build();
Job queryJob = bigquery.create(JobInfo.newBuilder(queryConfig).build());
queryJob = queryJob.waitFor(); // Wait for the query to complete.
return ((QueryJobConfiguration) queryJob.getConfiguration()).getDestinationTable();
}
References:
Google cloud documentation
GitHub repository
In Google app engine, how can i delete multiple data selected in check box. For a sample i had attached the image below. here i had selected the multiple check boxes and the data shown are stored in the Google app engine.
i have my jsp code for check box like this,
<input name="delete" type="checkbox"/>
can anyone suggest me how to select the data and delete it from Google app engine.
Edited:
For storing the data i used,
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Entity employee = new Entity("Employee");
employee.setProperty("First Name", fname);
datastore.put(employee);
For retrieving the data i used,
Query query = new Query("Employee");
List<Entity> emp = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(20));
for (Entity user : emp){
// inside the table
user.getProperty("File Name")}
By this i can retrieve the data.
First of all, I recommend that you use two frameworks to make your life easier:
Stripes
Objectify
OK, here you go: I'm not sure to which degree your question is a basic JSP/Servlet question or a specific Appengine question. However, you have to do the follwoing:
Have a list of checkboxes on your JSP page, like this: <stripes:checkbox name="employees[${loop.index}].id" value="${employee.id}"/> (see: http://www.stripesframework.org/display/stripes/Indexed+Properties)
Pass a list of IDs (of the entities that should be deleted) to the Servlet.
Delete the entities based on these IDs.
Here's the catch: Appengine can terminate the request before all entities are deleted. That can happen if the request takes too long. Therefore you should delete the entities asynchronously, using chunks of data. See this answer for further information.