My aim was to create a postgresql database through Java Program. The database name has consecutive Capital and small letters.
//Program to Create a Postgresql database
import java.io.*;
import java.sql.*;
public class CreateDatabase
{
public static void main(String[] args)
{
System.out.println("Database creation example!");
Connection oConnection = null;
try
{
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://172.x.x.x:5432/postgres";
oConnection = DriverManager.getConnection(url, "postgres", "12345");
System.out.println("Sucessfully connected to Postgres Database");
try
{
Statement st = oConnection.createStatement();
st.executeUpdate("CREATE DATABASE \"TeStDb\" WITH
OWNER=postgres ENCODING='UTF8';);
}
catch (Exception s)
{
System.out.println("SQL statement is not executed:-" + s);
}
}
catch (Exception e)
{
System.out.println("Exception:- "+e);
}
}
}
Thursday, December 23, 2010
Monday, December 13, 2010
Starting & Stopping services on Ubuntu bootup
my@my-desktop:~$ sudo su
Provide the command update-rc.d YOURSERVICENAME defaults in terminal.
root@my-desktop:/home/my# update-rc.d YOURSERVICENAME defaults
This will display the following:
Adding system startup for /etc/init.d/YOURSERVICENAME ...
/etc/rc0.d/K20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc1.d/K20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc6.d/K20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc2.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc3.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc4.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc5.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
Restart the PC. The service YOURSERVICENAME will be started automatically on PC boot up.
To remove the service on PC boot
Provide the command,update-rc.d YOURSERVICENAME remove in terminal.
root@my-desktop:/home/my# update-rc.d YOURSERVICENAME remove
Provide the command update-rc.d YOURSERVICENAME defaults in terminal.
root@my-desktop:/home/my# update-rc.d YOURSERVICENAME defaults
This will display the following:
Adding system startup for /etc/init.d/YOURSERVICENAME ...
/etc/rc0.d/K20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc1.d/K20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc6.d/K20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc2.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc3.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc4.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc5.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
Restart the PC. The service YOURSERVICENAME will be started automatically on PC boot up.
To remove the service on PC boot
Provide the command,update-rc.d YOURSERVICENAME remove in terminal.
root@my-desktop:/home/my# update-rc.d YOURSERVICENAME remove
Subscribe to:
Posts (Atom)