The Java Operations database appears (][sqlserver Driver for jdbc]error establishing socket.) The problem is the solution

Source: Internet
Author: User

when you perform a JDBC Direct operations database :

We need to carry out a guide to the project (the introduction of "Msbase.jar" "Mssqlserver.jar" "Msutil.jar" the three packages, the specific practice is)
Select the item that we want to import the package by hand, right click on the list of columns, select Properties, then select Java bukid Path in the panel, then check Add External Jars

, and finally select the package we want to import.

Graphic:

(1) (2)

This will import the required three packages into ..... But here comes the question again,

Class.forName ("Com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connect to SQL
ct = drivermanager.getconnection ("Jdbc:microsoft:sqlserver://localhost:1433;databasename=demo_1", "sa", " 869261636123 ");
PS = ct.preparestatement (SQL);
rs = Ps.executequery ();

When the code runs here, our most common problem is this error message][sqlserver the Driver for jdbc]error establishing socket.

Encounter this hint: say, that what, our socket failed to build, here is likely to be the port problem (General SQL Port is 1433 but there is likely to be a problem with other ports)

So we might as well check our port connectivity issues: Ctrl + R--cmd---> netstat-an---> Get what we're looking for

So we just need to change the port number from 1433 to 1434 on the line,

ct = drivermanager.getconnection ("Jdbc:microsoft:sqlserver://localhost:1434;d atabasename=demo_1", "sa", " 869261636123 ");

Then the problem is solved by the edge!!!  At this time is not also think of the king of the steamer of the steaming kui of laughter? hahaha ha ha haha haha ~~~~! End

Of course, when we first configure the environment, the data will appear garbled.  .... Well, of course, we'll know that this is due to the fact that the database and our compiler encode different formats, so we generally take some of these statements to deal with such problems:

For example: (rs.getstring (i)). GetBytes ("GBK"), "gb2312"); It's all right!

The Java Operations database appears (][sqlserver Driver for jdbc]error establishing socket.) The problem is the solution

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.