Today we are going to learn simple method to create the database and table from jsp code.
Just create a simple jsp page ex:create.jsp and paste the code below
<%@page import="java.sql.*,java.io.*" %>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/","root","root");
PreparedStatement ps=con.prepareStatement("create database s2sgateway");
ps.executeUpdate();
PreparedStatement ps1=con.prepareStatement("use s2sgateway");
ps1.executeUpdate();
PreparedStatement ps2=con.prepareStatement("create table new(name varchar(20))");
ps2.executeUpdate();
%>
database created sucessfully
Table create successfully
After executing you could see a database named s2sgateway and a table named new under s2sgateway has been created.
Here i use mysql if you use other database change the driver and connection settings accordingly any doubt ask us.
Happy coding