- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the MySQL datatype to store DATALINK object in JDBC
A DATALINK object represents an URL value which refers to an external resource (outside the current database/data source), which can be a file, directory etc..
MySQL does not provide any separate datatype to store DATALINK/URL value you need to store using TEXT or VARCHAR datatypes as shown in the following query −
CREATE TABLE tutorials_data ( tutorial_id INT PRIMARY KEY AUTO_INCREMENT, tutorial_title VARCHAR(100), tutorial_author VARCHAR(40), submission_date date, tutorial_link VARCHAR(255) );
Following JDBC program establishes a connection with MYSQL database, creates a table with name tutorials_data. In this table we are creating a column with name tutorial_link which stores an URL value, for this column, we are using VARCHAR as datatype.
Example
import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; public class CreateTable_Datalink { public static void main(String args[])throws Exception { //Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver()); //Getting the connection String mysqlUrl = "jdbc:mysql://localhost/sampledatabase"; Connection con = DriverManager.getConnection(mysqlUrl, "root", "password"); System.out.println("Connection established......"); //Creating a Statement object Statement stmt = con.createStatement(); //Query to create a tutorials_data table String query = "CREATE TABLE Customers(" + "ID INT NOT NULL, " + "NAME VARCHAR (20) NOT NULL, " + "AGE INT NOT NULL, " + "SALARY DECIMAL (18, 2), " + "ADDRESS VARCHAR (25), " + "Date Date, " + "PRIMARY KEY(ID))"; //Executing the query stmt.execute(query); System.out.println("Table created ........"); } }
Output
Connection established...... Table created ........
- Related Articles
- How to insert a DATALINK object into a table using JDBC?
- How to retrieve a DATALINK object from a table using JDBC?
- MySQL datatype to store month and year only?
- Which MySQL datatype to used to store an IP address?
- How to encrypt a CLOB datatype in JDBC?
- What is the best datatype for currencies in MySQL?
- What is RowId object in JDBC Explain?
- What is the smallest datatype for one bit in MySQL?
- What is the easiest way to store date in MySQL database?
- What is to be used to store floats in MySQL?
- What is JDBC Blob data type? how to store and read data from it?
- What is JDBC Clob data type? how to store and read data from it?
- What is the MySQL JDBC driver connection string?
- What is the best data type to store money values in MySQL?
- What is Result in JDBC? How to retrieve data from ResultSet object?

Advertisements