Probleme de compilation
titchouzaune
Messages postés
220
Statut
Membre
-
Marco la baraque Messages postés 1030 Statut Contributeur -
Marco la baraque Messages postés 1030 Statut Contributeur -
Bonjour,
jaimerais que ma methode stringQuery retourne un String mais jai un pb de compilation .
msg erreur (au niveau de string query): vous devez retourner un string
merci de votre aide
import java.sql.*;
public class GestionBasededonnee {
Connection connexion;
Statement statement;
// =================================================================================================
// ===== Constructeur responsable de l'initialisation de l'attribut connexion
// =================================================================================================
public GestionBasededonnee (String url, String user, String password) {
//Chargement du driver
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException PBdriver) {
System.err.println ("Probleme avec le chargement du driver");
System.err.println (PBdriver.getMessage());
}
//=== Connexion a la base
try {
connexion = DriverManager.getConnection("jdbc:mysql://localhost/poklo02?user=root&password=");
statement= connexion.createStatement();
}
catch (SQLException e0) {e0.toString();}
}
public ResultSet resultSetQuery (String requeteSQL) {
ResultSet resultat=null;
try {
resultat=statement.executeQuery(requeteSQL);
}
catch (SQLException e2) {e2.toString();}
return (resultat);
}
public String stringQuery (String requeteSQL) {
ResultSet res = null;
res=resultSetQuery(requeteSQL);
try {
while(res.next()){
System.out.println(res.getString(1));
}
}
catch (SQLException e4) {e4.toString();}
}
}
Voici un bout de mon programme thread :
while (rs.next())
{
int or=rs.getInt(1);
if (or==b){
//System.out.println("Bienvenue " + joueur.getname() );
//select note from etudiant where nom='totor'
GestionBasededonnee gestionmysql = new GestionBasededonnee("jdbc:mysql://localhost/poklo02","root","");
String op=gestionmysql.stringQuery("SELECT nom FROM liste_des_joueurs where IDconnex='"+b+"' ");
System.out.println("Bienvenue " + op );
}
}
jaimerais que ma methode stringQuery retourne un String mais jai un pb de compilation .
msg erreur (au niveau de string query): vous devez retourner un string
merci de votre aide
import java.sql.*;
public class GestionBasededonnee {
Connection connexion;
Statement statement;
// =================================================================================================
// ===== Constructeur responsable de l'initialisation de l'attribut connexion
// =================================================================================================
public GestionBasededonnee (String url, String user, String password) {
//Chargement du driver
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException PBdriver) {
System.err.println ("Probleme avec le chargement du driver");
System.err.println (PBdriver.getMessage());
}
//=== Connexion a la base
try {
connexion = DriverManager.getConnection("jdbc:mysql://localhost/poklo02?user=root&password=");
statement= connexion.createStatement();
}
catch (SQLException e0) {e0.toString();}
}
public ResultSet resultSetQuery (String requeteSQL) {
ResultSet resultat=null;
try {
resultat=statement.executeQuery(requeteSQL);
}
catch (SQLException e2) {e2.toString();}
return (resultat);
}
public String stringQuery (String requeteSQL) {
ResultSet res = null;
res=resultSetQuery(requeteSQL);
try {
while(res.next()){
System.out.println(res.getString(1));
}
}
catch (SQLException e4) {e4.toString();}
}
}
Voici un bout de mon programme thread :
while (rs.next())
{
int or=rs.getInt(1);
if (or==b){
//System.out.println("Bienvenue " + joueur.getname() );
//select note from etudiant where nom='totor'
GestionBasededonnee gestionmysql = new GestionBasededonnee("jdbc:mysql://localhost/poklo02","root","");
String op=gestionmysql.stringQuery("SELECT nom FROM liste_des_joueurs where IDconnex='"+b+"' ");
System.out.println("Bienvenue " + op );
}
}
A voir également:
- Probleme de compilation
- Breach compilation c'est quoi - Guide
- Erreur de compilation projet ou bibliothèque introuvable - Forum VB / VBA
- Message d'erreur Excel projet ou bibliotheque introuvable ! - Forum Excel
- Problème Compilation Dev-C++ - Forum C++
- Must declare a named package because this compilation unit is associated to the named module - Forum Java