Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

connection mysql pour applet java

3 réponses
Avatar
Loupiot
Bonjour à tous!
Je souhaiterais faire une applet java qui utiliserais la base mysql de lycos
multimania.
Comment faire pour gérer la connection? Suis je obligé de passer par une
page php?
Si oui comment faire? Si vous avez des liens interessants je suis aussi
preneur. Merci d'avance!

3 réponses

Avatar
yvon.thoravalNO-SPAM
Loupiot wrote:

Je souhaiterais faire une applet java qui utiliserais la base mysql de lycos
multimania.


pas de pb si tu as le driver : mysql-connector-java-3.0.9-stable-bin.jar

(par exemple)

Comment faire pour gérer la connection? Suis je obligé de passer par une
page php?


pas du tout.

À fin de tester ta connection, utilises ce petit script de Marc Liyanage
:
/*
* TestMySQL.java
*
*
* History:
*
* When Who What
*
======================================================================= ===== * 2001-07-23 Marc Liyanage First version, based on
TestPostgreSQL.java
*
*
* License:
*
* Copyright abandoned 2001 by Marc Liyanage
* Do with this whatever you want.
*
*/


import java.sql.*;




/**
* The TestMySQL class shows how to access the MySQL
* DB server on Mac OS X using the JDBC interface.
* It assumes the installation has been performed according
* to the instructions at http://www.entropy.ch/software/macosx/mysql/.
*
* It further assumes that the MM.MySQL JDBC driver jar file from
* http://mmmysql.sourceforge.net
* has been installed in /usr/local/lib/mysql/
*
*
* You compile it like this:
*
* % javac TestMySQL.java
*
* Run the program like this, make sure to adjust the classpath
* so it matches the version of the mm.mysql jar file you
* installed:
*
* % java -classpath /usr/local/lib/mysql/mm.mysql-2.0.4-bin.jar:.
TestMySQL
*
* You should see the current date as returned by the DB server:
*
* 2001-07-23 23:03:57
*
*
* @author Marc Liyanage
* @version 1.0
*/
public class TestMySQL {


public static void main(String argv[]) throws Exception {

// Load the driver class
//
Class.forName("org.gjt.mm.mysql.Driver");

// Try to connect to the DB server.
// We tell JDBC to use the "mysql" driver
// and to connect to the "test" database
// which should always exist in MySQL.
//
// We use the username "" and no
// password to connect. This should always
// work for the "test" database.
//
Connection conn = DriverManager.getConnection(
"jdbc:mysql:///test",
"",
""
);

// Set up and run a query that fetches
// the current date using the "now()" SQL function.
//
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("SELECT now();");

// Iterate through the rows of the result set
// (obviously only one row in this example) and
// print each one.
//
while (rset.next()) {
System.out.println(rset.getString(1));
}

// Close result set, statement and DB connection
//
rset.close();
stmt.close();
conn.close();

}


}

--
yt

Avatar
Kupee
Yvon Thoraval wrote:
Loupiot wrote:


Je souhaiterais faire une applet java qui utiliserais la base mysql de lycos
multimania.



pas de pb si tu as le driver : mysql-connector-java-3.0.9-stable-bin.jar


A condition que Lycos/Multimania autorise les connections a mysql de
l'extérieur ce qui n'est pas certain. Sinon il faudra bien passer par
php malheureusement


Avatar
yvon.thoravalNO-SPAM
Kupee wrote:


A condition que Lycos/Multimania autorise les connections a mysql de
l'extérieur ce qui n'est pas certain. Sinon il faudra bien passer par
php malheureusement


ah ouais passeke c local... (to Lycos/Multimania)
--
yt