use this code but first create a datasource using control panel /jdbcodbc
and select configure after selecting the required DB.
Create a table using the name in the coce or adjust to your requirements
import java.sql.*;
class temp
{
public static void main(
String args[])
{
Connection conn;
Statement stat;
ResultSet rs;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc

dbc:Friend");
stat = conn.createStatement();
rs = conn.createStatement().executeQuery("select * from Friend");
while(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getString(2));
}
String Name="linus",Phone="6360073";
//String Query="insert into Friend values ('Mihir','455747')";
String Query="insert into Friend Values ('" +Name+ "','" +Phone+ "')";
stat.executeUpdate(Query);
conn.close();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}