sabato 15 novembre 2008
Installare postgreSQL su Windows
Pubblicato da
lux
alle
14:45
0
commenti
Etichette: database, JDBC, postgreSQL, windows
sabato 15 marzo 2008
MySQL - SHOW STATUS in Java
// showstatus.java
import java.sql.*;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
class showstatus
{
private static Connection conDb;
// check the correct values of followings variables
private static String JDBC_DRIVER = "com.mysql.jdbc.Driver";
private static String JDBC_URL = "jdbc:mysql://127.0.0.1:3306/";
private static String JDBC_NAME = "root";
private static String JDBC_PASSWORD = "password";
public static void main(String[] args)
{
System.out.println( "Start" );
// driver
try
{
Class.forName( JDBC_DRIVER );
}
catch (Exception ex)
{
System.out.println( "Error Class.forName "+ex );
ex.printStackTrace();
System.exit(0);
}
// connection
try
{
conDb = DriverManager.getConnection(JDBC_URL, JDBC_NAME, JDBC_PASSWORD);
}
catch (Exception ex)
{
System.out.println( "Error getConnection "+ex );
ex.printStackTrace();
System.exit(0);
}
// Show Status
String query = "SHOW STATUS";
PreparedStatement ps;
ResultSet rs;
try
{
ps = conDb.prepareStatement(query);
try
{
rs = ps.executeQuery( query );
int cnt = 0;
try
{
while (rs.next()) // are there more 'Variable_name'?
{
String variableName = rs.getString("Variable_name");
String value = rs.getString("Value");
System.out.println( "variableName: "+variableName+" - Value: "+value );
// NOTE: value is String ...
// Is possible to convert it with the fllowing istruction:
// Integer.parseInt( value )); // only if numeric!!!
//System.out.println( "Integer.parseInt( value ) "+Integer.parseInt( value ));
}
}
catch (Exception ex)
{
System.out.println( "Error executeQuery "+ex );
ex.printStackTrace();
System.exit(0);
}
}
catch (Exception ex)
{
System.out.println( "Error executeQuery "+ex );
ex.printStackTrace();
System.exit(0);
}
}
catch (Exception ex)
{
System.out.println( "Error prepareStatement "+ex );
ex.printStackTrace();
System.exit(0);
}
System.out.println( "End" );
}
}
Pubblicato da
lux
alle
22:36
0
commenti
Etichette: java, JDBC, mysql, SHOW STATUS
mercoledì 6 febbraio 2008
Errore di connessione a MySQL
Se da Java eseguite una connessione a MySQL come la seguente
c=DriverManager.getConnection(" jdbc:mysql://192.168.1.2:3306/test","root", "password" );
e come risultato avete il seguente errore
java.sql.SQLException: null, message from server: "Host '192.168.1.4 is not allowed to connect to this MySQL server"
allora dovrete andare nella console locale di MySQL e fare così:
CREATE USER lux IDENTIFIED BY 'password';
GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO lux;
adesso cambiate l'istruzione in questo modo:c=DriverManager.getConnection( "jdbc:mysql://192.168.1.2:3306/test","lux", "password" );
Abilitate la porta TCP 3306 dal Firewall dove risiede il server MySQL e il gioco è fatto.
L'errore java.sql.SQLException è dovuto al fatto che volete accedere a root da un IP che non è localhost!!! L'accesso da root è meglio farlo solo da locale; da remoto potete abilitare tutti gli users che volete e dare i privilegi che volete (GRANT).
Pubblicato da
lux
alle
00:31
0
commenti
Etichette: Connection, JDBC, mysql
giovedì 15 novembre 2007
Le release di Java
Java 1.0 (Oak) 1995
Java 1.1
JDK 1.1.4 (Sparkler) September 12, 1997
JDK 1.1.5 (Pumpkin) December 3, 1997
JDK 1.1.6 (Abigail) April 24, 1998
JDK 1.1.7 (Brutus) September 28, 1998
JDK 1.1.8 (Chelsea) April 8, 1999
J2SE 1.2 (Playground) December 4, 1998
J2SE 1.2.1 (none) March 30, 1999
J2SE 1.2.2 (Cricket) July 8, 1999
J2SE 1.3 (Kestrel) May 8, 2000
J2SE 1.3.1 (Ladybird) May 17, 2001
J2SE 1.4.0 (Merlin) February 13, 2002
J2SE 1.4.1 (Hopper) September 16, 2002
J2SE 1.4.2 (Mantis) June 26, 2003
J2SE 5.0 (1.5.0) (Tiger) September 29, 2004
Java SE 6 (1.6.0) (Mustang) December 11, 2006 [3]
Java SE 7 (1.7.0) (Dolphin) anticipated for January 2009
Attualmente uso JDK7 1.7.0-ea-b23 (ovvero la build 23). Si può scaricare dal sito https://jdk7.dev.java.net/ (dopo essersi registrati).
Per vedere che versione di Java avete date il seguente comando dal prompt dei comandi:
- java -version
Pubblicato da
lux
alle
00:33
0
commenti
lunedì 30 luglio 2007
Bug nella stampa di JTextArea
Pubblicato da
lux
alle
23:49
5
commenti
Etichette: font, getStringBounds, grafica, graphics, IndexOutOfBoundsException, JDK7, JTextArea, multiline, printer, printing, stampa
domenica 22 luglio 2007
Jakarta Commons
Pubblicato da
lux
alle
02:47
0
commenti
lunedì 14 maggio 2007
JDBC: da DB2 a MySQL
giovedì 26 aprile 2007
Luxjava e Skype
Pubblicato da
lux
alle
00:44
0
commenti
Etichette: Skype
mercoledì 25 aprile 2007
Connessione a DB2
Argomenti trattati:
- JDBC
- Class.forName("com.ibm.db2.jcc.DB2Driver");
- String url = "jdbc:db2://127.0.0.1:50000/test"
- java.sql.Connection con = java.sql.DriverManager.getConnection(url, user, password);
- con.close();
- catch(java.sql.SQLException e)
Pubblicato da
lux
alle
23:09
0
commenti
Etichette: Class.forName, close(), Connection, DB2, getConnection, JDBC, SQLException
domenica 15 aprile 2007
luxjava
Ho intenzione di appoggiare il mio nuovo sito dedicato allo studio di java:
Ma perchè faccio un Blog di appoggio ad un sito web sul linguaggio java? Come ho intenzione di organizzarmi? Ecco una sintesi di quanto ho intenzione di fare:
- aggiungo un argomento al sito web
- metto nel sito web le spiegazioni sull'argomento
- metto nel sito web l'eventuale sorgente da scaricare
- aggiungo immagini sul sito web
- metto nel sito il link al blog relativo all'argomento
- aggiungo un post nel blog sull'argomento
- aggiungo eventuali immagini
- faccio il ri-post di commenti di maggior interesse nel sito web
Pubblicato da
lux
alle
22:14
1 commenti
Etichette: blog, http://www.luxjava.altervista.org/, java, luxjava