No data source is required for connecting to the database using JAVA.

Source: Internet
Author: User
I can see the following code on the Internet ::
<% Class. forName ("com. microsoft. jdbc. sqlserver. SQLServerDriver"). newInstance ();
String url = "jdbc: microsoft: sqlserver: // localhost: 1433; DatabaseName = shop"; // database name
String user = "sa ";
String password = "sa ";
Connection conn = DriverManager. getConnection (url, user, password );
Statement stmt = conn. createStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_UPDATABLE );
String SQL = "select * from userinfo ";
ResultSet rs1_stmt.exe cuteQuery (SQL );
While (rs. next ())
{%> The content of your first field is: <% = rs. getString (2) %>
Your second field content is: <% = rs. getString (3) %>
<% }%>
<% Out. print ("database operation successful, congratulations"); %>
<% Rs. close ();
Stmt. close ();
Conn. close ();
%>
After I copied it, I changed the database name and the table name. However, an error was reported when I browsed it under TOMCAT;

I am a beginner in JSP. Please give me some advice !! I wonder if the com. microsoft. jdbc. sqlserver. SQLServerDriver driver is not installed ??

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.