thanks for reply.
but i want to create database dynamically through jdbc .
in java to get connected we have to enter database name in getconnection() method.
[ Connection con = DriverManager.g etConnection("j dbc:postgresql://IpAddress:5432/" + databasename, dbusername, dbpassword); ]
but sice we don't have any database how to? & where to get connected?
how to create database at run time??
prepare a class name and do the follow code
//public final static String DRIVER = "com.mysql.jdbc .Driver";
//public final static String URL = "jdbc:mysql ://localhost/IA";
//public final static String USER = "";
//public final static String PASSWORD = "";
private static Properties dbprops = new Properties();
private static Driver myDriver = null;
private static Connection connection = null;
private static Statement statement1 = null;
public static void init() {
dbprops.put("us er", USER);
dbprops.put("pa ssword", PASSWORD);
try
{
myDriver = (Driver)Class.f orName(DRIVER). newInstance();
connection = DriverManager.g etConnection(UR L, dbprops);
try
{
Statement st = connection.crea teStatement();
BufferedReader bf = new BufferedReader( new InputStreamRead er(System.in));
String database = DATABASENAME; // "nlshriraam ";//bf.readLine();
st.executeUpdat e("CREATE DATABASE "+database) ;
}
catch (SQLException s)
{
}
}
catch (Exception e)
{
}
return;
}
hope this work
regards
NLShriraam