package toto;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
public class Gestion_SGBD {
private static Connection databaseConnection;
//The database connection
super();
// TODO Auto-generated constructor stub
jdbcDriver = _jdbcDriver;
url = _url;
username = _username;
password = _password;
System.
out.
println("Loading JDBC driver: " + jdbcDriver
);
try {
Class.forName (jdbcDriver);
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
System.
out.
println("Connection to : " + url
);
databaseConnection =
DriverManager.
getConnection (url, username, password
);
myRequest = databaseConnection.createStatement();
myResult = myRequest.executeQuery("SELECT " + columnName + " FROM " + tableName);
DataShow(myResult);
myRequest.close();
databaseConnection.close();
// TODO Auto-generated catch block
e.printStackTrace();
}
return myResult;
}
try
{
System.
out.
println ("Resultat: " );
int nbColonnes = myResultMetaData.getColumnCount();
for (int i = 1; i<nbColonnes+1; i++){
strRes.add(myResultMetaData.getColumnLabel(i));
}
for (int i = 0; i<strRes.size(); i++){
titre+=" | " + strRes.get(i);
}
while ( result.next() )
{
for (int i = 1; i<nbColonnes+1; i++){
res += " | " + result.getString(i);
}
}
}
{
System.
out.
println ("SQL Error: " + e
);
}
{
// NullPointerException might occur if property undefined
System.
out.
println ("Other Exception: " + e
);
}
}
}