0
I’m new here and this is my first question...
So I can’t at all connect SQL SERVER with NET BEANS.... I put JDBC already in the library folder, followed several types of tutorials on youtube and still can’t. The mistakes they’re making now if you want to understand them.
Exception in thread "main" java.lang.Noclassdeffounderror: javax/xml/bind/Datatypeconverter at com.microsoft.sqlserver.jdbc.Sqlserverconnection.sendLogon(Sqlserverconnection.java:4098) at com.microsoft.sqlserver.jdbc.Sqlserverconnection.logon(Sqlserverconnection.java:3160) at com.microsoft.sqlserver.jdbc.Sqlserverconnection.access$100(Sqlserverconnection.java:43) at com.microsoft.sqlserver.jdbc.Sqlserverconnection$Logoncommand.doExecute(Sqlserverconnection.java:3123) at com.microsoft.sqlserver.jdbc.Tdscommand.execute(Iobuffer.java:7505) at com.microsoft.sqlserver.jdbc.Sqlserverconnection.executeCommand(Sqlserverconnection.java:2445) at com.microsoft.sqlserver.jdbc.Sqlserverconnection.connectHelper(Sqlserverconnection.java:1981) at com.microsoft.sqlserver.jdbc.Sqlserverconnection.login(Sqlserverconnection.java:1628) at com.microsoft.sqlserver.jdbc.Sqlserverconnection.connectInternal(Sqlserverconnection.java:1459) at com.microsoft.sqlserver.jdbc.Sqlserverconnection.connect(Sqlserverconnection.java:773) at com.microsoft.sqlserver.jdbc.Sqlserverdriver.connect(Sqlserverdriver.java:1168) at java.sql/java.sql.Drivermanager.getConnection(Drivermanager.java:677) at java.sql/java.sql.Drivermanager.getConnection(Drivermanager.java:251) at projetoteste.Conector.connect(Connector.java:28) at projectste.Main.main(Main.java:27) Caused by: java.lang.Classnotfoundexception: javax.xml.bind.Datatypeconverter at java.base/jdk.internal.Loader.BuiltinClassLoader.loadClass(Builtinclassloader.java:583) at java.base/jdk.internal.Classloaders$Appclassloader.loadClass(Classloaders.java:178) at java.base/java.lang.Classloader.loadClass(Classloader.java:521) ... 15 more C: Users guga_ Documents Netbeansprojects projectTeste nbproject build-impl.xml:1328: The following error occurred while executing this line: C: Users guga_ Documents Netbeansprojects projectTeste nbproject build-impl.xml:948: Java returned: 1 BUILD FAILED (total time: 0 Seconds)
My classes are like this:
package projetoteste;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
*
* @author guga_
*/
public class Conector
{
public static Connection connect() throws ClassNotFoundException{
Connection con =null;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionURL="jdbc:sqlserver://localhost:1433;databaseName=guBanco;user=Honorato;password=1234";
try{
con=DriverManager.getConnection(connectionURL);
System.out.println("Connection is successfull");
}
catch(SQLException e){
System.out.println(e);
}
return con;
}
}
And the main class is that way:
package projetoteste;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import static projetoteste.Conector.connect;
/**
*
* @author guga_
*/
public class Main
{
public static void main(String[] args) throws ClassNotFoundException {
// TODO code application logic here
connect();
}
}
I searched long before asking this question here, so forgive me if it sounds silly... Thank you for your attention and for anyone who can help.
What version of jdk you are using ?
– Viktor Hugo
I am using version 11.0.2
– Gustavo Honorato
Good depending on the version of the JDBC driver does not have compatibility with java 11. in this link you find the most current version of mssql_jdbc or you can right-click the project -> properties -> categories: run -> VM options: add this argument: --add-modules java.xml.bind . This last option doesn’t work if your project needs to run in java 8 !
– Viktor Hugo