Skip to Content

How to upload text files into MaxDB Database instances using Java? – Part 1

This is a simple weblog which explains how text files can be inserted into MaxDB database instances. Although this is a simple operation but it is a mandatory and most required feature for any Database server. MySQL server has special datatypes like blob to store the file contents, but like MaxDB uses the existing datatypes like LONG, VARCHAR to store the same, with a slight modification. The modification is nothing but setting the code type as BYTE.

Create a BYTE type field

The files can be uploaded to a field that has the code type as BYTE. The below image shows a sample table with a field for storing a file content.


Next any text file can be uploaded into that field which will not exceed the size alloted. For huge files use the LONG data type with the same code type. In this weblog the below shown sample text file will be uploaded into the MaxDB database.


JDBC Program to upload file

Then a java program is to be developed that will upload the file into the database. Here the steps to be followed are
1. Declare a file reader to get the contents of the file.
2. Declare a byte variable to store the contents of the file.
3. Insert the byte data into the database.

JDBC Program to upload file

Executing Queries and Result


Checking the uploaded

A simple check for the uploaded file using SQLSTUDIO.


This is a very simple weblog. Hope this was useful to you.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply