problem with jre and jdk in eclipse to connect with mysql

0

Good morning, I am trying to connect a database with my code but at the time of executing the following exception:

  

"the JAR fie C: \ Program Files \ Java \ Jre1.8.0_151 \ ext \ mysql-connector-java-8.07-dmr-bin.jar has no source attachment. You can attach the source by clicking Attach Source below "

I've already tried it with other .jar mysql and even then, I thank you in advance for your contributions to solve the problem.

package prode;
import java.sql.*;

public class Conexion {

Connection con;
Statement st;

public Conexion(){
    try{Class.forName("com.mysql.jdbc.Driver"); // en el debug llega a esta parte mostrando por class file editor la excepción; en ejecución no lanza errores, llega al catch mostrando conexión no establecida
 con = DriverManager.getConnection("jdbc:mysql://localhost/prodemios?user=root&password=");

    }catch(ClassNotFoundException|SQLException e){
        System.out.println("conexion no establecida");
    }
}

}

They gave me the solution to change the jre to jdk, but in doing so, it launches the following Error occurred during initialization of VM java.lang.UnsatisfiedLinkError: java.io.FileInputStream.available () I     at java.io.FileInputStream.available (Native Method)     at sun.nio.cs.StreamDecoder.inReady (Unknown Source)     at sun.nio.cs.StreamDecoder.implRead (Unknown Source)     at sun.nio.cs.StreamDecoder.read (Unknown Source)     at java.io.InputStreamReader.read (Unknown Source)     at java.io.BufferedReader.fill (Unknown Source)     at java.io.BufferedReader.readLine (Unknown Source)     at java.io.BufferedReader.readLine (Unknown Source)     at sun.misc.MetaIndex.registerDirectory (Unknown Source)     at sun.misc.Launcher $ ExtClassLoader $ 1.run (Unknown Source)     at sun.misc.Launcher $ ExtClassLoader $ 1.run (Unknown Source)     at java.security.AccessController.doPrivileged (Native Method)     at sun.misc.Launcher $ ExtClassLoader.getExtClassLoader (Unknown Source)     at sun.misc.Launcher. (Unknown Source)     at sun.misc.Launcher. (Unknown Source)     at java.lang.ClassLoader.initSystemClassLoader (Unknown Source)     at java.lang.ClassLoader.getSystemClassLoader (Unknown Source)

Actually I'm working empirically and I'm not sure if I did well to change jre 151 to jdk 161 or 162 that it was with those who made the changes in the installed JREs, I looked for a jdk 151 to know if that was why the error but I can not find it, please ask for your help on this subject, thank you very much.

    
asked by pangloss 25.01.2018 в 14:38
source

1 answer

0

The way to fix the error would be to change from using jre to using jdk within Eclipse.

Within eclipse go to menu Windows-> Preferencias-> Java-> JRE instalados .

Select Browse and navigate to the C:\Archivos de programa\Java\jdk1.8.0_151 directory.

Eclipse will automatically search for the source and associate it with the JDK classes.

If you still want to use jre in eclipse, enter the Windows-> Preferences-> JRE instaladas en Java menu.

Select the jre that you are using. Click on Edit In the resulting dialog box, select all jar files.

Click on the Source Attachment button. Navigate to the src.zip file referenced in your message and select it.

    
answered by 25.01.2018 в 18:50