Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Database Connection Problem-SQL SERVER 2005

843859Mar 19 2008 — edited Mar 20 2008
Dear all,

I have been struggling with this database connection.I have installed sql server 2005 in my PC and i am trying to connect to the Database Adventity.But it is showing port 1432 invalid.I have placed sqljdbc jar in my lib folder.If i dont specify Database name then it will print hi Message..if i specify Database name then the error will come.

MY CODE is::

<%@page import="java.sql.*,java.io.*,java.lang.*,java.util.*,java.util.Vector,bean.*" %>
<%

Connection con;
Statement stmt;
String url= "jdbc:sqlserver://156.0.11.140:1433/Adventity";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(url,"sa","hcl@123");
stmt = con.createStatement();
out.println("hi");

%>

THE ERROR IS:
javax.servlet.ServletException: The port number 1433/Adventity is not valid.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.adv1_jsp._jspService(adv1_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

root cause

PLEASE HELP ME TO GET RID OUT FROM THIS PROBLEM.
THANKS IN ADVANCE.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 17 2008
Added on Mar 19 2008
8 comments
144 views