Ken Shamrock

Ranch Hand
+ Follow
since Jan 23, 2002
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 Ken Shamrock

Hello all,

To me, processing language like chinese in jsp/servlet is a nightmare...
I try to process chinese words from the form and insert it to DB, it stores unknown code...in reverse, it can't display Chinese words where query from DB..

I wonder if I can get BOTH traditional Chinese and simplified Chinese from the form and incert it to DB? Or display it from DB?

If not, just process simplifed Chinese wording is ok...thank you all..
11 years ago
JSP
I try to place all mssql *.jar into \tomcat\common\lib

I compile my java file with "import com.microsoft.jdbc.sqlserver.*;"
it says

"DBConn.java:5: package com.microsoft.jdbc.sqlserver does not exist
import com.microsoft.jdbc.sqlserver.*;"

but if I extract the mssql jar files into tomcat\common\lib\com\microsoft\jdbc\sqlserver.
it can, how can I fix the problem? Thanks
Hi all, I haven't come to this forum for 2 years as I have not play programming for a period, now I come back.

In the past, when I use tomcat with MySQL, I get a connection pool java made by someone and use it with Servlet, now, I will use jsp/servlet with Database MSSQL, I wonder if I still need to use connection pool anymore? Or MSSQL can take care of the connections? Thanks
It's powerful! Below is a code for creating Excel via Servlet, please improve it together, do you think there's any room for improvement? Like need any threading?

import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.poi.hssf.usermodel.*;

public class HSSFExcelCreator extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
}

public void destroy() {
}

/** Processes requests for both HTTP GET and POST methods.
* @param request servlet request
* @param response servlet response
*/

protected void processRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

response.setContentType("application/vnd.ms-excel");
//response.setHeader("Content-Disposition", "inline; filename=\"my.xls\"");
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");

// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow((short)0);

// Create a cell and put a value in it.
HSSFCell cell = row.createCell((short)0);

cell.setCellValue(1);

// Or do it on one line.
row.createCell((short)1).setCellValue(1.2);
row.createCell((short)2).setCellValue("This is a string");
row.createCell((short)3).setCellValue(true);
// Write the output
OutputStream out = response.getOutputStream();
wb.write(out);
out.close();
}

/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/

protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}

/** Handles the HTTP POST method.
* @param request servlet request
* @param response servlet response
*/

protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}

/** Returns a short description of the servlet.
*/

public String getServletInfo() {
return "Example to create a workbook in a servlet using HSSF";
}
}
13 years ago
In the past, I used to make use of connection pool when connecting to MySQL using Servlet; now, I will connect Oracle via Servlet, I wonder if I still need to make a connecting pool in Servlet? Or Oracle already have this kind of function so that I don't need to take care of this when programming? Thanks
13 years ago
Thanks Hemanth Pallavajula, William Brogden had pointed out the official site of POI

There's a few ref link I found:
http://www.devx.com/Java/Article/17301?
http://www.unc.edu/~smyre/poi/poi_jj.html
http://jakarta.apache.org/poi/hssf/how-to.html

What I need is user inputed search criteria, Servlet go to Oracle to get the result and output reports in excel format, since output are report, they do need formatting. Also, one important issue why I need more than one spreadsheet is because Excel have 65535 rows limit, if data is more than 65535 rows, then it will have problem..
13 years ago
Hello all

If I need to output data as Excel format for users in front of their browser (it includes more than 1 spreadsheet), must I make use of POI?

If so, how? The process: User submit the search criteria, Servlet operate and call POI, POI generate file on the server (am i right?), then how can it popup the excel files in front of the browser??

If there's some sample code on how Servlet use POI, it should be great help, I can't find such sample code on net, thanks very much

Ken
13 years ago
I execute this SQL in MSSQL and prompt me a timeout box, i wonder how i can set the MSSQL's query timeout?
SQL:
SELECT c.theme_title, c.grade_id, b.sub_theme_title, count(a.cd)
FROM hit_rates_report_log a, sub_theme b, theme c
WHERE a.type = 'SUBTHEME' AND a.cd = b.sub_theme_cd AND
b.theme_cd = c.theme_cd AND (access_time >= '2003-6-15 00:00:00') AND
(access_time <= '2003-7-15 23:59:59') AND b.theme_cd IN
(SELECT theme_cd
FROM theme_lang_link
WHERE lang_cd = 'CHI')
GROUP BY c.theme_title, c.grade_id, b.sub_theme_title, a.cd
UNION
SELECT e.theme_title, e.grade_id, d .sub_theme_title, 0
FROM sub_theme d, theme e
WHERE NOT EXISTS
(SELECT 'X'
FROM hit_rates_report_log f
WHERE f.type = 'SUBTHEME' AND f.cd = d .sub_theme_cd AND
e.theme_cd = d .theme_cd AND (access_time >= '2003-6-15 00:00:00') AND
(access_time <= '2003-7-15 23:59:59') AND d .theme_cd IN
(SELECT theme_cd
FROM theme_lang_link
WHERE lang_cd = 'CHI'))
ORDER BY c.theme_title, b.sub_theme_title

If I break the union and query the 2 SQL one by one,no timeout, ie
SQL1:
SELECT c.theme_title, c.grade_id, b.sub_theme_title, count(a.cd)
FROM hit_rates_report_log a, sub_theme b, theme c
WHERE a.type = 'SUBTHEME' AND a.cd = b.sub_theme_cd AND
b.theme_cd = c.theme_cd AND (access_time >= '2003-6-15 00:00:00') AND
(access_time <= '2003-7-15 23:59:59') AND b.theme_cd IN
(SELECT theme_cd
FROM theme_lang_link
WHERE lang_cd = 'CHI')
GROUP BY c.theme_title, c.grade_id, b.sub_theme_title, a.cd
SQL2:
SELECT e.theme_title, e.grade_id, d .sub_theme_title, 0
FROM sub_theme d, theme e
WHERE NOT EXISTS
(SELECT 'X'
FROM hit_rates_report_log f
WHERE f.type = 'SUBTHEME' AND f.cd = d .sub_theme_cd AND
e.theme_cd = d .theme_cd AND (access_time >= '2003-6-15 00:00:00') AND
(access_time <= '2003-7-15 23:59:59') AND d .theme_cd IN
(SELECT theme_cd
FROM theme_lang_link
WHERE lang_cd = 'CHI'))
ORDER BY c.theme_title, b.sub_theme_title
I made this one, seem to be work, need to test:
SELECT a.ip, name, SUM(hits)
FROM table1 a LEFT JOIN
table2 b ON a.ip = b.ip
WHERE time > '2001' OR
time = NULL
GROUP BY a.ip, a.name
UNION
SELECT c.ip, c.name, 0
FROM table1 c
WHERE NOT EXISTS
(SELECT 'X'
FROM table2 d
WHERE d .ip = c.ip)

I want to join them with 127.0.0.3 SHOWN in NEW TABLE even it have no
hits (in table2)
mysql> select a.ip,name,time,sum(hits) from table1 a left join table2 b
on a.ip=
b.ip group by a.ip,a.name;

But if I specify the time ( > 2000 ) using where time>'2001' , I can't
get what my want (Also show 127.0.0.3)
What can the SQL do to do what I want? Many thanks!!
mysql> select a.ip,name,time,sum(hits) from table1 a left join table2 b
on a.ip=
b.ip where time>'2001' OR time=null group by a.ip,a.name;

PS: Pls be remind that this all can be do in MSSQL but not MYSQL. Thanks
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ July 18, 2003: Message edited by: Dirk Schreckmann ]
I have two tables- table1 & table2

I want to join them with 127.0.0.3 SHOWN in NEW TABLE even it have no
hits (in table2)
mysql> select a.ip,name,time,sum(hits) from table1 a left join table2 b
on a.ip=
b.ip group by a.ip,a.name;

But if I specify the time ( > 2000 ) using where time>'2001' , I can't
get what my want (Also show 127.0.0.3)
What can the SQL do to do what I want? Many thanks!!
mysql> select a.ip,name,time,sum(hits) from table1 a left join table2 b
on a.ip=
b.ip where time>'2001' OR time=null group by a.ip,a.name;

pls read here if you cant see above:
http://www.hk3s.com/db.txt
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ July 18, 2003: Message edited by: Dirk Schreckmann ]
Please read the question in this link as the above is hard to read:
http://www.hk3s.com/db.txt

mysql> select a.ip,name,time,sum(hits) from table1 a left join table2 b on a.ip=
b.ip group by a.ip,a.name;

mysql> select a.ip,name,time,sum(hits) from table1 a left join table2 b on a.ip=
b.ip where time>'2001' OR time=null group by a.ip,a.name;
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ July 18, 2003: Message edited by: Dirk Schreckmann ]
what comes to my mind is 1)diary, 2)organizer, 3)newsgroup gateway 4)personal homepage editor
but those things are too general..
14 years ago

Originally posted by <Paggadaisy Dunlio>:
You could install a Don Liu Chatbot, thats lots of fun for the dwarfs



mmmmmmmmmm, have their any samples around for us to take a look?
14 years ago