wood burning stoves 2.0*
The moose likes JDBC and the fly likes Problem in Connecting to remote database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem in Connecting to remote database" Watch "Problem in Connecting to remote database" New topic
Author

Problem in Connecting to remote database

Varma dandu
Greenhorn

Joined: Apr 29, 2005
Posts: 16
Hi dudues,

I am using the following code in connecting to remote sqlserver 7 database on windows platform.I am on linux platform.I was able to ping remote ip.


<html><head></head>
<body>
<%@ page import="java.sql.*" %>
<%

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();

%>
<% Connection conn = DriverManager.getConnection
("jdbc dbc:QUIZTV://192.168.200.50:1433","quiz_u","yiaphlup");
Statement stmt = conn.createStatement();
ResultSet columns = stmt.executeQuery("select * from CallQueue");
while(columns.next())
{
String cli= columns.getString("cli");
String status= columns.getString("status");
%>
<%=cli%>
<%}%>
</body>
</html>

I am getting the following exception :

root cause

java.lang.NullPointerException
sun.jdbc.odbc.JdbcOdbcDriver.initialize(JdbcOdbcDriver.java:436)
sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:153)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.test1_jsp._jspService(test1_jsp.java:53)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Just wondering whether anyone could help me in this regard.

Thanks
Varma Dandu.
Jeremy Wilson
Ranch Hand

Joined: Feb 18, 2003
Posts: 166
do you have odbc drivers installed and configured on the linux box.


Jeremy Wilson
Amarender Reddy
Ranch Hand

Joined: May 12, 2005
Posts: 54
hi!

can anyone explain me the above <%=cli%> stmt

cheers

amar
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by amarender reddy:
can anyone explain me the above <%=cli%> stmt

This is JSP syntax, used to reduce the amount of Java code mixed with HTML code.
It is equivalent to the following:

... where 'out' is the output stream being sent to the client.
If you have any follow-up questions you should ask them in the JSP forum.

Dave
Varma dandu
Greenhorn

Joined: Apr 29, 2005
Posts: 16
Thanx geremey for ur reply,

I've got the windows box now and had created datasource for remote database using control panel.

I have used this datasource(ds) and used the url "jdbcdbcs" and i was able to make the connection now.

Should we use the same procedure if i had to work on linux box.
if so, how do i configure odbc drivers on linux box.

Thanx in advance.
Varma dandu.

[edited to disable smilies]
[ May 16, 2005: Message edited by: Jeanne Boyarsky ]
slav agui
Greenhorn

Joined: Jan 15, 2008
Posts: 4
Did you find a solution to your problem?
I am experiencing exactly same problem.
Works perfect on my pc but when it is deployed in a unix box I am getting same error.

Any help is appreciated....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in Connecting to remote database