Download and install SQLite and the SQLite
SQLite is a serverless database system in which the database will be a single file on the computer. More information about the same is available at Wikipedia .
Create the Bank
import java.sql.*;
public class SQLiteJDBC
{
public static void main( String args[] )
{
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
System.out.println("Banco aberto com sucesso");
}
}
Create a table
import java.sql.*;
public class SQLiteJDBC
{
public static void main( String args[] )
{
Connection c = null;
Statement stmt = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
System.out.println("Banco de dados fora aberto com sucesso");
stmt = c.createStatement();
String sql = "CREATE TABLE TABELA " +
"(ID INT PRIMARY KEY NOT NULL," +
" NOME TEXT NOT NULL, " +
" IDADE INT NOT NULL)";
stmt.executeUpdate(sql);
stmt.close();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
System.out.println("A tabela TABELA foi criada com sucesso");
}
}
Note: You could use Access (I do not recommend focusing on local usage). But it would have to make the connection anyway the only difference is that the host of your db would be localhost
. If you want to see how to use Access, I suggest that you see this link