aspose file tools
The moose likes JDBC and the fly likes Connection with database... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Connection with database..." Watch "Connection with database..." New topic
Author

Connection with database...

yunuss khan
Greenhorn

Joined: Apr 22, 2006
Posts: 17
Hi All,

I want to retreive records from database but i have one problm in the below Code where should i pass my Server name and Database name..because my data is on server not on my local database..in below code "Data" is my database name and "Cust" is my tablename..

Pls help.....

<%@ page import="java.sql.*" %>

<% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); %>

<HTML>
<HEAD>
<TITLE>Selecting tableName From a Database</TITLE>
</HEAD>

<BODY>
<H1>Selecting tableName From a Database</H1>

<%
Connection connection = DriverManager.getConnection(
"jdbcdbc:data", "userName", "password");

Statement statement = connection.createStatement() ;
ResultSet resultset =
statement.executeQuery("select * from cust where city = 'Boston'") ;
%>

<TABLE BORDER="1">
<TR>
<TH>ID</TH>
<TH>Name</TH>
<TH>City</TH>
<TH>State</TH>
<TH>Country</TH>
</TR>
<% while(resultset.next()){ %><TR>
<TD> <%= resultset.getString(1) %></td>
<TD> <%= resultset.getString(2) %></TD>
<TD> <%= resultset.getString(3) %></TD>
<TD> <%= resultset.getString(4) %></TD>
<TD> <%= resultset.getString(5) %></TD>
</TR>
<% } %>
</TABLE>
</BODY>
</HTML>


Thanks & Regards,
Yunus
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1318

Originally posted by yunuss khan:




hi yunus,

A database on a remote server requires more information, however. If the database is to be accessed over the Internet, for example, the network address should be included in the JDBC URL as part of the parameter.


[ December 08, 2006: Message edited by: Saif uddin ]

Saifuddin..
[Linkedin] How To Ask Questions On JavaRanch My OpenSource
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Connection with database...
 
Similar Threads
Problem with database connectivity
Fetching information from database in jsp
I want to display the details of employee. in prescribed format
Deplyoing a JSP page in Sun One Application server 7
retreiving data through jsp