import java.sql.*;
public class DBConnect {
/**
* @param args
*/
public static void main(String[] args) {
Connection connection = null;
try {
String driverName = "com.mysql.jdbc.Driver"; // MySQL MM JDBC driver
Class.forName(driverName);
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/databaseName", "userName", "password");
}
catch (Exception e) {
e.printStackTrace();
}
Statement stmt;
String s;
String own;
try {
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM pet");
while (rs.next()) {
// Get the data from the row using the column name
s = rs.getString("name");
own = rs.getString("owner");
System.out.println(s + " owned by " + own);
}
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
Thursday, July 30, 2009
Tuesday, July 28, 2009
My adventures with DB
First step
I was introduced to MS access when I was about 12 years old. To be frank I understand nothing then.
Rebirth
My 2nd introduction to DB was when I was 24 to Oracle. since then I have been studying DBs.
Following is solely my opinion and I do not recommend anyone to follow them. Of course no liability what so ever will be admitted.
MS Access
Our little friend. The best place to get started with DB.
Pros:
1. Intuitive interface
2. Easy imports and exports to other file formats.
3. Easy installation
4. No maintenance
Cons:
1. Poor SQL interface
2. Cannot be used as fully pledged DB server
MySQL
The free guy with lot of talents
Pros:
1. Free
2. Production level DB server
2. Easy to install
Cons:
1. No built GUI
Oracle
Pros:
1. Production level
2. Free version is available
Cons:
1. Messy to maintain.
2. Messy to get started
3. No built in GUI
DB interfaces
DB interfaces add GUI to oracle and mySQL servers
Toad for mySQL
Pros:
1. Free
2. Easy installation
3. Intuitive interface
Cons:
1. One query at a time
2. Importing data from other file formats is bit poor.
Toad for Oracle
Pros:
1. Good functionality
2. Concurrent connections
3. Lot of tools to manage the DB
Cons:
1. Cluttered window. Not even slightly intuitive
2. Free version is a crippled version
SQL developer
Pros:
1. Free
2. Nice object browser
3. Very intuitive interface
Cons:
1. Support only xls and csv file imports
PL/SQL developper
Pros:
1. Intuitive interface
Cons:
1. Lower level support for maintenance
I was introduced to MS access when I was about 12 years old. To be frank I understand nothing then.
Rebirth
My 2nd introduction to DB was when I was 24 to Oracle. since then I have been studying DBs.
Following is solely my opinion and I do not recommend anyone to follow them. Of course no liability what so ever will be admitted.
MS Access
Our little friend. The best place to get started with DB.
Pros:
1. Intuitive interface
2. Easy imports and exports to other file formats.
3. Easy installation
4. No maintenance
Cons:
1. Poor SQL interface
2. Cannot be used as fully pledged DB server
MySQL
The free guy with lot of talents
Pros:
1. Free
2. Production level DB server
2. Easy to install
Cons:
1. No built GUI
Oracle
Pros:
1. Production level
2. Free version is available
Cons:
1. Messy to maintain.
2. Messy to get started
3. No built in GUI
DB interfaces
DB interfaces add GUI to oracle and mySQL servers
Toad for mySQL
Pros:
1. Free
2. Easy installation
3. Intuitive interface
Cons:
1. One query at a time
2. Importing data from other file formats is bit poor.
Toad for Oracle
Pros:
1. Good functionality
2. Concurrent connections
3. Lot of tools to manage the DB
Cons:
1. Cluttered window. Not even slightly intuitive
2. Free version is a crippled version
SQL developer
Pros:
1. Free
2. Nice object browser
3. Very intuitive interface
Cons:
1. Support only xls and csv file imports
PL/SQL developper
Pros:
1. Intuitive interface
Cons:
1. Lower level support for maintenance
Subscribe to:
Posts (Atom)