Shantanu Rathore

Greenhorn
+ Follow
since Feb 12, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shantanu Rathore

Re-posting with code tags:-

Hi
I have just started learning Swing.

What I am trying to do: Creating an application which will retrieve some data from a Oracle Database.

What I have done so far: I am trying to connect to the Database first and I wish to proceed further once the connection is established.

PROBLEM: I am getting the following error when I run the application: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

Code:- (this is just the code for the Button Click. Filename:DesktopApplicationView.java )




Some Facts:-
*The database I am trying to connect to is huge. Is that a problem? I tried connecting to the database through a standalone program and it worked.
*I tried to make a separate class to do all the database related work and call it through this class but it throws the same error.
Hi
I have just started learning Swing.

What I am trying to do:
Creating an application which will retrieve some data from a Oracle Database.

What I have done so far:
I am trying to connect to the Database first and I wish to proceed further once the connection is established.

PROBLEM: I am getting the following error when I run the application: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

Code:- (this is just the code for the Button Click. Filename:DesktopApplicationView.java )

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:
String s=null;
String ret_msg;
String messg=null;
Object env_name=jComboBox1_EnvNames.getSelectedItem();
s=env_name.toString();
jTextField2.setText(s);
Connection conn;//This is the point from where I feel the real problem begins

try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@10.*.*.*:1523:oron","user","pass");

ret_msg="Connection to the DB Established";


}
catch (ClassNotFoundException c)
{
ret_msg=c.toString();
System.out.println(ret_msg);
}
catch (SQLException sq_ex)
{
ret_msg=sq_ex.toString();
System.out.println(ret_msg);
}


jTextField3.setText(ret_msg); //I am expecting it to return: 'Connection to the DB Established' but instead it returns the error message.

}


Some Facts:-
*The database I am trying to connect to is huge. Is that a problem? I tried connecting to the database through a standalone program and it worked.
*I tried to make a separate class to do all the database related work and call it through this class but it throws the same error.
*I am new to Swing...just started yesterday...so anything which makes you say

<removed inappropriate content>






[jc: removed four letter words from the post. Please mind your language]
Dear Ulf,

You are right. If I show the whole file then:-

1. It asks the user to open the file/save it.
2. If I chose open, then it shows the file in the screen and asks the user whether he/she wants to save the changes made if any thing is changed in the file.
3. If I chose open and make no changes and close the file after viewing it, it closes without saving.

I am not sure whether it is save somewhere in the temporary internet files.

I need to display some part of the excel sheet on the screen. Hence I have used poi.
I am working on displaying the code in a tabular format using table tags.

I didn't figure out:"then POI has no part in this - you would just stream the file to the client with an appropriate content type, and let the browser deal with it."

Thanks a lot.

Shantanu
Hi,

What I am trying to do: Reading an Excel sheet from a remote location and passing it on to a JSP page.

What I have managed so far: I have managed to read the Excel Sheet from the remote location. This was done using a Java class and POI.

What I need help with:
1. How to pass the Excel Sheet(retrieved in the java file) to a JSP page which will display the excel sheet. I have researched somethings but am not clear how to go about doing it.
2. I am OK with the JSP page opening the excel sheet separately, but is it possible to display it within the JSP page itself? I was wondering about using iFrames but i think its client side basically. Is it possible to use it in a JSP?

Code Snippets:-

ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

//baos is a ByteArrayOutputStrream whichread the Excel sheet from the remote location.

//POI Coding to read the excel file
POIFSFileSystem fs = new POIFSFileSystem(bais);
HSSFWorkbook wb = new HSSFWorkbook(fs);

Application FLow:- A HTML(user enters the filename here) ==> passes filename to ==> JSP==> passes filename to ==>Java (retrieves file)
Java==> passes File to ==>JSP : DISPLAYS THE FILE


Thanks in advance.


@Ulf: Thanks. I ll keep it in mind to code the part in a java file. Thanks for pointing out the libraries to read CSV files.
14 years ago
JSP
Hi Everyone,

Requirement: TO read a CSV file and transferring the content into an array which I can display on a JSP/HTML screen.

Description:-
1. I want to read a CSV file stored in a particular location on my computer.
2. As per my understanding, the CSV file is a comma separated file with each line representing a row in a table. The columns are separated by commas.
3. I want to store the CSV file contents in an array in exactly the same structure as the original tabular format.
4. Then I want to display the file on a JSP screen or a HTML screen in tabular format again.

Notes:-
The CSV file I have is a pretty big one because it has a lot of data. The data is mostly 'string'.

Since this is the first time I am trying something like this I dont have any idea about the code. Can anyone help me out with a small example explaining me how to go about doing this?

Thank you all in advance. Eagerly awaiting a response. Thanks

Shantanu
14 years ago
JSP