Hot questions for Using Ubuntu in jdbc

Question:

I am using Ubuntu 12.05 and trying to connect to a Windows Server 2012 for a database

my database name is jobs the ip address of the pc is 192.160.1.33

which is hosted in 1433 yet when i try to connect it gives the following error

WARNING: Failed to load the sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path

Please advice how to set that.


Answer:

I think you have the wrong jdbc driver and you're on Ubuntu 12.04 (there is no 12.05). Rather then hacking around with an old native driver for Windows (Linux libraries end in .so not .dll), I suggest you stop and use this Type-4 one from Microsoft. By definition, a type-4 driver uses no native libraries.

Question:

I am reading about JDBC in OCP Java book, and in this book, it explains about JavaDB and before running my code, I need to add derby.jar file to my classpath.

java −cp "/my/jdk/home/db/lib/derby.jar:." SetupDerbyDatabase

OS: Ubuntu 19.04

Java version: 8


Answer:

The JDK is being slimmed down and derby is no longer part of the distribution.

You must download the jar manually and then use the path to the downloaded jar instead of the one you use today.

Question:

I would like to execute my .jmx program (delevoped on jmeter for windows) on my Ubuntu server but when I launch the following command: jmeter -n -t TestRemote.jmx -l log.jtl I receive this exception in jmeter.log

15/04/30 09:39:27 INFO  - jmeter.util.JMeterUtils: Setting Locale to en_US 2015/04/30 09:39:27 INFO  - jmeter.JMeter: Loading user properties from: /opt/apache-jmeter-2.13/bin/user.properties
2015/04/30 09:39:27 INFO  - jmeter.JMeter: Loading system properties from: /opt/apache-jmeter-2.13/bin/system.properties
2015/04/30 09:39:27 INFO  - jmeter.JMeter: Copyright (c) 1998-2012 The Apache Software Foundation
2015/04/30 09:39:27 INFO  - jmeter.JMeter: Version 2.8.20130705
2015/04/30 09:39:27 INFO  - jmeter.JMeter: java.version=1.7.0_79
2015/04/30 09:39:27 INFO  - jmeter.JMeter: java.vm.name=OpenJDK 64-Bit Server VM
2015/04/30 09:39:27 INFO  - jmeter.JMeter: os.name=Linux
2015/04/30 09:39:27 INFO  - jmeter.JMeter: os.arch=amd64
2015/04/30 09:39:27 INFO  - jmeter.JMeter: os.version=3.13.0-34-generic
2015/04/30 09:39:27 INFO  - jmeter.JMeter: file.encoding=UTF-8
2015/04/30 09:39:27 INFO  - jmeter.JMeter: Default Locale=English (United States)
2015/04/30 09:39:27 INFO  - jmeter.JMeter: JMeter  Locale=English (United States)
2015/04/30 09:39:27 INFO  - jmeter.JMeter: JMeterHome=/usr/share/jmeter
2015/04/30 09:39:27 INFO  - jmeter.JMeter: user.dir  =/opt/apache-jmeter-2.13/bin
2015/04/30 09:39:27 INFO  - jmeter.JMeter: PWD       =/opt/apache-jmeter-2.13/bin
2015/04/30 09:39:27 INFO  - jmeter.JMeter: IP: 10.4x.x.184 Name: jmeter FullName: jmeter.x.x
2015/04/30 09:39:27 INFO  - jmeter.services.FileServer: Default base='/opt/apache-jmeter-2.13/bin'
2015/04/30 09:39:27 INFO  - jmeter.services.FileServer: Set new base='/opt/apache-jmeter-2.13/bin'
2015/04/30 09:39:27 INFO  - jmeter.JMeter: Loading file: TestRemote.jmx
2015/04/30 09:39:27 INFO  - jmeter.save.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2
2015/04/30 09:39:27 INFO  - jmeter.save.SaveService: Using SaveService properties file encoding UTF-8
2015/04/30 09:39:27 INFO  - jmeter.save.SaveService: Using SaveService properties file version 1382180
2015/04/30 09:39:27 INFO  - jmeter.save.SaveService: Using SaveService properties version 2.3
2015/04/30 09:39:27 INFO  - jmeter.save.SaveService: All converter versions present and correct
2015/04/30 09:39:27 ERROR - jmeter.save.SaveService: Conversion error com.thoughtworks.xstream.converters.ConversionException: org.apache.jmeter.protocol.jdbc.config.DataSourceElement : org.apache.jmeter.protocol.jdbc.config.DataSourceE$
---- Debugging information ----
message             : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
converter-type      : org.apache.jmeter.save.converters.HashTreeConverter
path                : /jmeterTestPlan/hashTree/hashTree/JDBCDataSource
line number         : 80
------------------------------- : org.apache.jmeter.protocol.jdbc.config.DataSourceElement : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
---- Debugging information ----
message             : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
converter-type      : org.apache.jmeter.save.converters.HashTreeConverter
path                : /jmeterTestPlan/hashTree/hashTree/JDBCDataSource
line number         : 80
-------------------------------
message             : org.apache.jmeter.protocol.jdbc.config.DataSourceElement : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
---- Debugging information ----
message             : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
converter-type      : org.apache.jmeter.save.converters.HashTreeConverter
path                : /jmeterTestPlan/hashTree/hashTree/JDBCDataSource
line number         : 80
-------------------------------
cause-exception     : com.thoughtworks.xstream.converters.ConversionException

I added jdbc connector for Mysql database to apache-jmeter-2.13\lib on my server. How can i resolve this issue?

EDIT: Adding jdbc connector for mysql to apache-jmeter-2.13\lib\ext I obtain this error:

2015/05/04 10:07:36 INFO  - jmeter.util.JMeterUtils: Setting Locale to en_US
2015/05/04 10:07:36 INFO  - jmeter.JMeter: Loading user properties from: /opt/apache-jmeter-2.13/bin/user.properties
2015/05/04 10:07:36 INFO  - jmeter.JMeter: Loading system properties from: /opt/apache-jmeter-2.13/bin/system.properties
2015/05/04 10:07:36 INFO  - jmeter.JMeter: Copyright (c) 1998-2012 The Apache Software Foundation
2015/05/04 10:07:36 INFO  - jmeter.JMeter: Version 2.8.20130705
2015/05/04 10:07:36 INFO  - jmeter.JMeter: java.version=1.7.0_79
2015/05/04 10:07:36 INFO  - jmeter.JMeter: java.vm.name=OpenJDK 64-Bit Server VM
2015/05/04 10:07:36 INFO  - jmeter.JMeter: os.name=Linux
2015/05/04 10:07:36 INFO  - jmeter.JMeter: os.arch=amd64
2015/05/04 10:07:36 INFO  - jmeter.JMeter: os.version=3.13.0-34-generic
2015/05/04 10:07:36 INFO  - jmeter.JMeter: file.encoding=UTF-8
2015/05/04 10:07:36 INFO  - jmeter.JMeter: Default Locale=English (United States)
2015/05/04 10:07:36 INFO  - jmeter.JMeter: JMeter  Locale=English (United States)
2015/05/04 10:07:36 INFO  - jmeter.JMeter: JMeterHome=/usr/share/jmeter
2015/05/04 10:07:36 INFO  - jmeter.JMeter: user.dir  =/opt/apache-jmeter-2.13/bin
2015/05/04 10:07:36 INFO  - jmeter.JMeter: PWD       =/opt/apache-jmeter-2.13/bin
2015/05/04 10:07:36 INFO  - jmeter.JMeter: IP: 10.4x.x.184 Name: jmeter FullName: jmeter.x.x
2015/05/04 10:07:36 INFO  - jmeter.services.FileServer: Default base='/opt/apache-jmeter-2.13/bin'
2015/05/04 10:07:36 INFO  - jmeter.services.FileServer: Set new base='/opt/apache-jmeter-2.13/bin'
2015/05/04 10:07:36 INFO  - jmeter.JMeter: Loading file: TestRemote.jmx
2015/05/04 10:07:37 INFO  - jmeter.save.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2
2015/05/04 10:07:37 INFO  - jmeter.save.SaveService: Using SaveService properties file encoding UTF-8
2015/05/04 10:07:37 INFO  - jmeter.save.SaveService: Using SaveService properties file version 1382180
2015/05/04 10:07:37 INFO  - jmeter.save.SaveService: Using SaveService properties version 2.3
2015/05/04 10:07:37 INFO  - jmeter.save.SaveService: All converter versions present and correct
2015/05/04 10:07:37 ERROR - jmeter.save.SaveService: Conversion error com.thoughtworks.xstream.converters.ConversionException: org.apache.jmeter.protocol.jdbc.config.DataSourceElement : org.apache.jmeter.protocol.jdbc.config.DataSourceE$
---- Debugging information ----
message             : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
converter-type      : org.apache.jmeter.save.converters.HashTreeConverter
path                : /jmeterTestPlan/hashTree/hashTree/JDBCDataSource
line number         : 80
------------------------------- : org.apache.jmeter.protocol.jdbc.config.DataSourceElement : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
---- Debugging information ----
message             : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
converter-type      : org.apache.jmeter.save.converters.HashTreeConverter
path                : /jmeterTestPlan/hashTree/hashTree/JDBCDataSource
line number         : 80
-------------------------------
message             : org.apache.jmeter.protocol.jdbc.config.DataSourceElement : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
---- Debugging information ----
message             : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
converter-type      : org.apache.jmeter.save.converters.HashTreeConverter
path                : /jmeterTestPlan/hashTree/hashTree/JDBCDataSource
line number         : 80
-------------------------------
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : org.apache.jmeter.protocol.jdbc.config.DataSourceElement : org.apache.jmeter.protocol.jdbc.config.DataSourceElement
first-jmeter-class  : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:65)
class               : org.apache.jmeter.save.ScriptWrapper
required-type       : org.apache.jorphan.collections.ListedHashTree
converter-type      : org.apache.jmeter.save.ScriptWrapperConverter
path                : /jmeterTestPlan/hashTree/hashTree/JDBCDataSource
line number         : 80
version             : 2.8.20130705
-------------------------------
2015/05/04 10:07:37 ERROR - jmeter.JMeter: Error in NonGUIDriver java.lang.NullPointerException
        at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:93)
        at org.apache.jmeter.JMeter.runNonGui(JMeter.java:745)
        at org.apache.jmeter.JMeter.startNonGui(JMeter.java:723)
        at org.apache.jmeter.JMeter.start(JMeter.java:388)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.jmeter.NewDriver.main(NewDriver.java:216)

EDIT: i tried to run a simple code only with BeanShell sampler (log.info("Hello");) and however it didn't work and it threw this exception:

2015/05/07 12:28:51 ERROR - jmeter.save.SaveService: Conversion error com.thoughtworks.xstream.converters.ConversionException: org.apache.jmeter.protocol.java.sampler.BeanShellSampler : org.apache.jmeter.protocol.java.sampler.BeanShellSampler

this is my jmx program:

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.8" jmeter="2.13 r1665067">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">1</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1430993955000</longProp>
        <longProp name="ThreadGroup.end_time">1430993955000</longProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="BeanShell Sampler" enabled="true">
          <stringProp name="BeanShellSampler.query">log.info(&quot;ciao&quot;);</stringProp>
          <stringProp name="BeanShellSampler.filename"></stringProp>
          <stringProp name="BeanShellSampler.parameters"></stringProp>
          <boolProp name="BeanShellSampler.resetInterpreter">false</boolProp>
        </BeanShellSampler>
        <hashTree/>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

Answer:

Looks like JMeter needs your JDBC classes during start-up. Place your jdbc jars in jmeter\lib\ext folder.

Question:

Essential parts of the Code: (Taken from example from Book: Java How to Program 10th ed, By: Paul Deitel, Harvey Deitel (p. 1063)):

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DisplayAuthors 
{
    public static void main(String args[])
    {
        final String DATABASE_URL = "jdbc:derby:books";

        try (  
                Connection connection =
                DriverManager.getConnection(DATABASE_URL, "user", "pass"); 
            )
        {
            // ...
        }
        catch (SQLException sqlException)                                
        {                                                                  
            sqlException.printStackTrace();
        }                                                   
    } 
}

I'm on Ubuntu 16.04

Although Java website for Java DB says the db is included in JDK, I have learned after few hours of web searches that openJDK java, the recommended install on Ubuntu, does not come with the java db.

The website that had that helpful information suggested to run:

sudo apt-get install sun-javadb-client sun-javadb-core

Which produced error and did not install.

So I downloaded jdk-8u111-linux-x64.tar.gz, extracted as instructed, and just to be safe(I believe, I could have just set JAVA_HOME, DERBY_HOME to extracted location, and which did "half-worked" upto ij parts[see below]), removed everything from my /usr/lib/jvm/java-8-openjdk-amd64/ and replaced with the content of what I downloaded.

And added these in my .bashrc:

JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
DERBY_HOME=/usr/lib/jvm/java-8-openjdk-amd64/db
export DERBY_HOME

Entered in terminal to create database and insert data as instructed in book:

$JAVA_HOME/db/bin/ij
connect 'jdbc:derby:books;create=true;user=usr;password=pass';
run 'book-basic-table-create-and-insertions.sql';
exit;

It produces a file books with db info+/data inside it.

At ./ there's also a file named derby.log that contains these informations:

----------------------------------------------------------------
Wed Dec 14 19:01:58 EST 2016:
Booting Derby version The Apache Software Foundation - Apache Derby - 10.11.1.2 - (1629631): instance a816c00e-0158-ffc9-1471-000006d047c8 
on database directory /tmp/deleteme-IuI/books with class loader sun.misc.Launcher$AppClassLoader@6f94fa3e 
Loaded from file:/usr/lib/jvm/java-8-openjdk-amd64/db/lib/derby.jar
java.vendor=Oracle Corporation
java.runtime.version=1.8.0_111-b14
user.dir=/tmp/deleteme-IuI
os.name=Linux
os.arch=amd64
os.version=4.4.0-53-generic
derby.system.home=null
Database Class Loader started - derby.database.classpath=''
----------------------------------------------------------------
Wed Dec 14 19:04:25 EST 2016: Shutting down Derby engine
----------------------------------------------------------------
Wed Dec 14 19:04:27 EST 2016:
Shutting down instance a816c00e-0158-ffc9-1471-000006d047c8 on database directory /tmp/deleteme-IuI/books with class loader sun.misc.Launcher$AppClassLoader@6f94fa3e 
----------------------------------------------------------------

Compiled and ran:

javac DisplayAuthors.java # compiles without error
java DisplayAuthors

Program outputs:

java.sql.SQLException: No suitable driver found for jdbc:derby:books
at java.sql.DriverManager.getConnection(DriverManagerager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.javaava:247)
at DisplayAuthors.main(DisplayAuthors.java:15)

How do I get the program to work?


Answer:

You are missing the load driver section of code

e.g.

String driver = "org.apache.derby.jdbc.EmbeddedDriver";
...
try {
    Class.forName(driver); 
} catch(java.lang.ClassNotFoundException e) {
  ...
}

see http://docs.oracle.com/javadb/10.8.3.0/getstart/rwwdactivity3.html for an example

Edit

As a proof I have done the following

  1. create simple java project in Eclipse
  2. add derby.jar, derbynet.jar & derbyclient.jat to classpath

My Code

public static void main(String[] args) {

    String driver = "org.apache.derby.jdbc.EmbeddedDriver";
    try {
        Class.forName(driver); 
    } catch(java.lang.ClassNotFoundException e) {
        e.printStackTrace();
    }

    final String DATABASE_URL = "jdbc:derby:myDB;create=true;user=user;password=pass";

    try (  
            Connection connection = DriverManager.getConnection(DATABASE_URL, "user", "pass"); 
        )
    {
        // ...
    }
    catch (SQLException sqlException)                                
    {                                                                  
        sqlException.printStackTrace();
    }        

}

This runs without Exceptions

Question:

A sever issue I am facing after deployment on Glassfish4 and Ubuntu 14.04 . In java, I am not using hibernate due to some reasons. I am manually getting the resultset as a result of query, sending the result set to JSP page and iterating over it.

Problem is, I have set the finally block as below:

 finally {
            try {

                if (conn != null) {
                    conn.close();
                }
                if (ctx != null) {
                    ctx.close();
                }
                if (cstatement != null) {
                    cstatement.closeOnCompletion();
                }

            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

            } catch (NamingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

And because I am sending the Resultset to JSP page through session, I am closing the result on JSP page as follows:

if(resultset!=null) resultset.close();

Now, problem is, after few minutes my application starts giving exception that max of the connection pools has been used.

What should I do to avoid exception?


Answer:

The problem with your current finally block is:

If any exception is thrown from one of the close command, the following command will not be run. Since the issue seems to be resource leak so that might be the cause.

If you are running under JDK7+ and the resource is auto-closable, try to use

try(Connection conn=DriverManager.getConnection();
  Statement stat=conn.createStatement){
}

Then the resources will be closed safely exiting try block.

And if you need to close resource from finally block, try to wrap a try catch for each close statement.

For ordering of closing resource, always close the resource you created later first.

Question:

I am running Ubuntu 16.04 and using Oracle Java 9.

$ java --version
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

I have installed SQL Server jdbc driver (sqljdbc_6.2.2.0_enu.tar.gz in https://www.microsoft.com/en-us/download/details.aspx?id=55539)

$ ls /home/t/program_files/RDBMS/JDBC/mssqlserverjdbc_6.0/enu/jre*
/home/t/program_files/RDBMS/JDBC/mssqlserverjdbc_6.0/enu/jre7:
sqljdbc41.jar

/home/t/program_files/RDBMS/JDBC/mssqlserverjdbc_6.0/enu/jre8:
sqljdbc42.jar

I wrote some simple code to test using the driver :

// JDBC driver name and database URL                                                                                                                                       
String JDBC_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
// static final String DB_URL = "jdbc:mysql://localhost/"; // connect to a DBMS                                                                                            
String DB_URL = "jdbc:microsoft:sqlserver://localhost/STUDENTS"; // connect to a specific database in a DBMS                                                               
//  Database credentials                                                                                                                                                   
String USER = "SA";
String PASS = "password";

//Register JDBC driver                                                                                                                                                     
try{
    Class.forName(JDBC_DRIVER);
}catch(Exception e){ //Handle errors for Class.forName                                                                                                                     
    e.printStackTrace();
}

    //Open a connection                                                                                                                                                    
System.out.println("Connecting to database...");

try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS); // connect to DBMS, not to a DB                                                                     
    Statement st = conn.createStatement()){

}catch(SQLException se){ //Handle errors for JDBC                                                                                                                          
    se.printStackTrace();
}

Compilation is fine:

$ javac BasicOperations.java

Running isn't.

$ java -cp .:/home/t/program_files/RDBMS/JDBC/mssqlserverjdbc_6.0/enu/jre8/sqljdbc42.jar BasicOperations

Connecting to database...
java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://localhost/STUDENTS
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:703)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
        at BasicOperations.main(BasicOperations.java:46)

How shall I solve the problem?

Is it because I am using Java 9 and SQL Server jdbc driver has drivers for jre7 and jre8?

Thanks.


Answer:

Looks like format of database connection URL is incorrect. Please check https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url

To be specific: microsoft: should be removed from URL. This is the format:

jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;p‌​roperty=value[;prope‌​rty=value]]