In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to set up MyEclipse's JDBC-related drivers". In daily operation, I believe many people have doubts about how to set up MyEclipse's JDBC-related drivers. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to set MyEclipse's JDBC-related drivers". Next, please follow the editor to study!
Register the JDBC driver for MyEclipse
The purpose of registering the JDBC driver for MyEclipse is to tell the JDBC driver manager which driver to load. When you use the class.forName function to load a driver, you must specify the name of the driver. The following is the name of the Microsoft SQL Server 2000 JDBC driver:
Com.microsoft.jdbc.sqlserver.SQLServerDriver
The following code example shows how to register a driver:
Driver d = (Driver) Class.forName ("com.microsoft.jdbc.sqlserver.SQLServerDriver") .newInstance ()
Transfer connection URL
Database connection information must be passed in the form of a connection URL. The following is the template URL for the Microsoft SQL Server 2000 JDBC driver. Replace the following values with the values of your database:
Jdbc:microsoft:sqlserver://servername:1433
The following code example shows how to specify a connection URL:
Con = DriverManager.getConnection ("jdbc:microsoft:sqlserver://localhost:1433", "userName", "password")
The server name value can be an IP address or a hostname (assuming your network can resolve the hostname to an IP address). You can verify that the response can be received and that the IP address of the response is correct by executing the PING command against the hostname.
The numeric value after the server name is the port number on which the database listens. The values listed above are sample default values. Be sure to replace the value with the port number used by your database.
For a complete list of connection URL parameters, see the Microsoft SQL Server 2000 JDBC driver HTML help, or see the online guide. See the "connection string Properties" section.
The following code example attempts to connect to a database and displays the database name, version, and available catalog. Replace the server attribute in the code with the value of your server:
Package com.axiom; import java.sql.*; public class JDBC {public static void main (String [] args) {try {Class.forName ("com.microsoft.jdbc.sqlserver.SQLServerDriver") .newInstance (); System.out.println ("registered successfully!") ; String URL = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=NorthWind"; String user = "sa"; String password = "sa"; Connection conn = DriverManager.getConnection (URL,user,password); System.out.println ("connection successful!") ; Statement st; st = conn.createStatement (); ResultSet rs; rs = st.executeQuery ("select top 10 * from Orders"); while (rs.next ()) {System.out.println (rs.getString ("ShipCity"));} catch (Exception e) {e.printStackTrace (); System.out.println ("connection failed!") ;}
If successful, it will appear:
Registered successfully!
Connection successful!
Reims M ü nster Rio de Janeiro Lyon Charleroi Rio de Janeiro Bern Gen è ve Resende San Crist ó bal-byaxiom1433;DatabaseName=JSPTest "
Notice the difference between the two in the JDBC of MyEclipse
At this point, the study on "how to set up the JDBC-related drivers for MyEclipse" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.