Posts in "Code Base"

Java Date format

Here i will provide list of Java Date formats that are used in Java frequently. There are different ways you can achieve the same result in Java. 1- Using Predefined Format You can directly use DateFormat class to format date in predefined style. DateFormat has predefined 4 styles which can be used for quick formatting… Continue reading

How to Create Table in Oracle Using statement in Java

import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.Scanner; /* * Here we will learn to Create Table in DB using JDBC Statements in Oracle and MySQL DB */ public class CreateTableWithStatement { public static void main(String[] args) { String tableCreateQuery = "create table JBT(name varchar2(10), course varchar2(10))"; Statement statement = null; Connection connection… Continue reading

How to connect to mysql database in java

Here we will learn to connect to MYSQL DB via Java. import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Scanner; /* * Here we will learn to connect to Oracle DB using JDBC Driver. */ public class ConnectMySQLDB { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out .println("Please provide below details to… Continue reading