Navigation

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    SOLVED Connexion à ma base de donné échoué

    1.7.x
    1.7.10
    3
    5
    932
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Snyker
      Snyker last edited by

      Bonjour, ( je revient àprèèèèèèèèèèès longtemps d’absence rt )

      Je souhaite pouvoir crée une base de donné dans mon mod malheureusement il n’arrive pas à me le crée/charger.

      Code erreur:
      :::

      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/local
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.sql.DriverManager.getConnection(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.sql.DriverManager.getConnection(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.degraduck.minefus.proxy.SQL.connection(SQL.java:25)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.degraduck.minefus.Minefus.preInit(Minefus.java:39)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Method.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Method.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.post(EventBus.java:275)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Method.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.post(EventBus.java:275)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:513)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:239)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.Minecraft.run(Minecraft.java:931)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.main.Main.main(Main.java:164)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Method.invoke(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
      [20:31:01] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at GradleStart.main(Unknown Source)
      

      :::

      Code SQL :
      :::

      private Connection connection;
      private String urlbase, host, database, user, pass;
      
      public SQL(String urlbase, String host, String database, String user, String pass){
      this.urlbase = urlbase;
      this.host = host;
      this.database = database;
      this.user = user;
      this.pass = pass;
      }
      
         public Connection connection() {
             if(!this.isConnected()) {
                 try {
                     connection = DriverManager.getConnection(urlbase + host + "/" + database, user, pass);
                     System.out.println("connexion a la BDD reussi");
                 } catch (SQLException var2) {
                     var2.printStackTrace();
                 }
             }
      
             return null;
         }
      
         public Connection deconnection() {
             if(this.isConnected()) {
                 try {
                     this.connection.close();
                     System.out.println("BDD deconnecter");
                 } catch (SQLException var2) {
                     var2.printStackTrace();
                 }
             }
      
             return null;
         }
      
         public boolean isConnected() {
             return this.connection != null;
         }
      

      :::

      Code Main class:
      :::

      public class Minefus {
      
      @Instance("modminefus")
      public static Minefus instance;
      public SQL sql;
      
      @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
      public static CommonProxy proxy;
      
      public static CreativeTabs BlockMinefusCreativeTabs = new BlockMinefusCreativeTabs("blockminefus_creative_tabs");
      
      @EventHandler
      public void preInit(FMLPreInitializationEvent event)
      {
      M_Block.init();
      M_BlockMulti.init();
      this.sql = new SQL("jdbc:mysql://","localhost","local","root","");
      this.sql.connection();
      
      }
      
      @EventHandler
      public void init(FMLInitializationEvent event)
      {
      proxy.registerRender();
      }
      
      @EventHandler
      public void postInit(FMLPostInitializationEvent event)
      {
      
      }
      

      :::

      1 Reply Last reply Reply Quote 0
      • robin4002
        robin4002 Administrateurs Rédacteurs Moddeurs confirmés last edited by

        Salut,
        As-tu ajouté la bibliothèque mysql-connector-java ?

        1 Reply Last reply Reply Quote 0
        • Snyker
          Snyker last edited by

          Heu non je savais même pas qu’il fallait un truc de ce genre O_o
          C’est trouvable sur google?

          1 Reply Last reply Reply Quote 0
          • AymericRed
            AymericRed last edited by

            Java ne gère pas tout seul la connection aux bdd, il faut une lib qui fait ça, et oui c’est trouvable (https://www.google.fr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=mysql connector java).

            1 Reply Last reply Reply Quote 0
            • Snyker
              Snyker last edited by

              [21:55:58] [Client thread/INFO] [STDOUT]: [com.degraduck.minefus.proxy.SQL:connection:26]: connexion a la BDD reussi

              Merci 😄

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Design by Woryk
              Contact / Mentions Légales / Faire un don

              MINECRAFT FORGE FRANCE © 2018

              Powered by NodeBB