Sandeep Jain

Ranch Hand
+ Follow
since Oct 25, 2000
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 Sandeep Jain

Hello Guys,

I am facing a strange problem with JDBC Connection.

I have used Classes12.zip, oracle9i.jar,ojdbc14.jar as the Driver.

The Program is as follows.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.*;
import java.sql.ResultSet;

public class x {

public static void main(String[] args) throws Exception {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc racle:thin:@172.21.4.63:1521 00FR1", "xyz", "xyz");


String query = "select * from cdr where phone_number=? AND day_of_year between 291 AND 292 " ;
PreparedStatement stmt = conn.prepareStatement(query);
stmt.clearParameters();
stmt.setString(1,"+552192223293");
ResultSet rs = stmt.executeQuery();


/* String query = "select * from cdr where phone_number='+552192223293' AND day_of_year between 291 AND 292" ;
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
*/
if(rs.next())
System.out.println("Successful");
else
System.out.println("Unsuccessful");
rs.close();
stmt.close();
conn.close();
}
}
When I Comment the Prepared Statement and use normal Statement the query comes out very fast however When I use Prepared Satement it just hangs .

The Load in the Table is around 2000 million. and the Phone number is indexed. and day_of_year is partitioned.

Any help is appriciated as to why Prepared Staement is hanging.

Thanks in Advance

Sandeep Jain
Hi ,
I feel u will get only 1 item back from the existing program as u are not appending the item item_id
Every time the request come to the server a item_id is created with 1 element.
So what u have to do is , first get the array from session add the new element to it and then put the array back in the session .
21 years ago
hello guys ,
I am trying to read mails from mail server. Everything is Ok, except that I am not able to read the files properly which comes as attachment.
ie after storing it on the disk, when i open the file I see all junk charecters in it .
What I notice is, all the mails are comming with
application/ms-tnf format . I tried searching on the net an came accross a package which says that ms-tnef formats are in encoded format.
The package provides the api , however even after that i am not able to read the mails.
following is the site address which provides package for reading tnef formats
if anyone is able to read attchament please send me the code.
This is very urgent for me ....
Any suggestions are welcome...
Thanks in Advance
21 years ago
Hey guys ,
I am using javas mail package. and trying to reading and send mails . The problem that I am facing is with attachments.
1) I am unable to read the attachment file name.
it always gives me null however I can read the attachment
2)After reading the attachment when i try to open it , it opens it with all junk charecters in it.

import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class msgshow1
{
static String protocol="pop3";
static String host = "bbbbb";
static String user = "hhhhh";
static String password = "kkkk";
static String mbox = "INBOX";
static String url = null;
static int port = -1;
static boolean verbose = false;
static boolean debug = false;
static boolean showStructure = false;
static String indentStr = " ";
static int level = 0;
public static void main(String argv[])
{
int msgnum = 1;
try
{

Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
Store store = null;
store = session.getStore(protocol);
store.connect(host, port, user, password);
Folder folder = store.getDefaultFolder();
if (folder == null)
{
System.out.println("No default folder");
System.exit(1);
}
folder = folder.getFolder(mbox);
if (folder == null)
{
System.out.println("Invalid folder");
System.exit(1);
}
try
{
folder.open(Folder.READ_WRITE);
}
catch (MessagingException ex)
{
folder.open(Folder.READ_ONLY);
}
int totalMessages = folder.getMessageCount();
if (totalMessages == 0)
{
System.out.println("Empty folder");
folder.close(false);
store.close();
System.exit(1);
}
System.out.println("Getting message number: " + msgnum);
Message m = null;
try
{
m = folder.getMessage(msgnum);
dumpPart(m);
}
catch (IndexOutOfBoundsException iex)
{
System.out.println("Message number out of range");
}
folder.close(false);
store.close();
}
catch (Exception ex)
{
ex.printStackTrace();
}
System.exit(1);
}
public static void dumpPart(Part p) throws Exception
{

if (p instanceof Message)
dumpEnvelope((Message)p);
/** Dump input stream ..
InputStream is = p.getInputStream();
// If "is" is not already buffered, wrap a BufferedInputStream
// around it.
if (!(is instanceof BufferedInputStream))
is = new BufferedInputStream(is);
int c;
while ((c = is.read()) != -1)
System.out.write(c);
**/
String disp = p.getDisposition();
System.out.println("disp="+disp);
pr("CONTENT-TYPE: " + p.getContentType());
/*
* Using isMimeType to determine the content type avoids
* fetching the actual content data until we need it.
*/
if (p.isMimeType("text/plain"))
{
pr("This is plain text");
pr("---------------------------");
if (!showStructure)
System.out.println((String)p.getContent());
}
else if (p.isMimeType("multipart/*"))
{
pr("This is a Multipart");
pr("---------------------------");
Multipart mp = (Multipart)p.getContent();
level++;
int count = mp.getCount();
for (int i = 0; i < count; i++)
dumpPart(mp.getBodyPart(i));
level--;
}
else if (p.isMimeType("message/rfc822"))
{
pr("This is a Nested Message");
pr("---------------------------");
level++;
dumpPart((Part)p.getContent());
level--;
}
else if (!showStructure)
{
Object o = p.getContent();
if (o instanceof String)
{
pr("This is a string");
pr("---------------------------");
System.out.println((String)o);
}
else if (o instanceof InputStream)
{
System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+p.getFileName());
pr("This is just an input stream");
pr("---------------------------");
InputStream is = (InputStream)o;
//System.out.println("Filename = "+p.getFileName());
FileOutputStream outputStream = new FileOutputStream ("c:/doc1.doc");
/*System.out.println("The Total number Of bytes available ="+is.available());
byte b[]=new byte[is.available()];
is.read(b,0,is.available());
FileOutputStream outputStream = new FileOutputStream ("c:/doc1.doc");
outputStream.write(b);
outputStream.close();*/



int c;
while ((c = is.read()) != -1)
{
outputStream.write(c);
outputStream.flush();
System.out.write(c);
}
outputStream.close();
}
else
{
pr("This is an unknown type");
pr("---------------------------");
pr(o.toString());
}
}
else
{
pr("This is an unknown type");
pr("---------------------------");
}
}
public static void dumpEnvelope(Message m) throws Exception
{
pr("This is the message envelope");
pr("---------------------------");
Address[] a;
// FROM
if ((a = m.getFrom()) != null)
{
for (int j = 0; j < a.length; j++)
pr("FROM: " + a[j].toString());
}
//TO
if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
for (int j = 0; j < a.length; j++)
pr("TO: " + a[j].toString());
}
pr("SUBJECT: " + m.getSubject());
Date d = m.getSentDate();
pr("SendDate: " +(d != null ? d.toString() : "UNKNOWN"));
Flags flags = m.getFlags();
StringBuffer sb = new StringBuffer();
Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags
boolean first = true;
for (int i = 0; i < sf.length; i++)
{
String s;
Flags.Flag f = sf[i];
if (f == Flags.Flag.ANSWERED)
s = "\\Answered";
else if (f == Flags.Flag.DELETED)
s = "\\Deleted";
else if (f == Flags.Flag.DRAFT)
s = "\\Draft";
else if (f == Flags.Flag.FLAGGED)
s = "\\Flagged";
else if (f == Flags.Flag.RECENT)
s = "\\Recent";
else if (f == Flags.Flag.SEEN)
s = "\\Seen";
else
continue; // skip it
if (first)
first = false;
else
sb.append(' ');
sb.append(s);
}
String[] uf = flags.getUserFlags(); // get user-flag strings
for (int i = 0; i < uf.length; i++)
{
if (first)
first = false;
else
sb.append(' ');
sb.append(uf[i]);
}
pr("FLAGS: " + sb.toString());
String[] hdrs = m.getHeader("X-Mailer");
if (hdrs != null)
pr("X-Mailer: " + hdrs[0]);
else
pr("X-Mailer NOT available");
}
public static void pr(String s)
{
if (showStructure)
System.out.print(indentStr.substring(0, level * 2));
System.out.println(s);
}
}
21 years ago
Hello Femi ,
U can create another class extending from Dialog or JDialog and ur problem will be solved.
All u need to do is On click of the button initiate the new class which extends from Dialog
and set its VSisible property to true. and give some size.
21 years ago
ResultSet object is never returned as null if no rows are returned from database.
A ResultSet maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row.
21 years ago
Hello Guys,
I am inserting some values from jsp into oracle and I get this error:- ORA-00900
If i execute the same query from sql plus -it works , i mean the values get inserted in the database.
Any idea as to why this can happpen.???
Any help is appriciated
Hello Everyone,
I am stuck with a requiremnt where by I have to show a directory structure in a tree format however the each directory or a file has a unique number with which it is recognised.
Now how do I set a different export value for each node or a directory .
Please help me out as it is very important .
21 years ago
Well , what I feel here there is no way u can achieve this fuctionality without modifying the MultipartRequest.java file .
So what u can do is inside the constructor of MultipartRequest file u can check for the file type or ur condition on which u want to put ur file in the respective directory and make the call to its other constructor which takes 2 parameters and can set the direcory also .
21 years ago
Hello,
Generally , the images are not put in the database as it increases the load on the database by around 400% and what is generally followed is u put all the images in a particular directory on ur webserver. u just store the filename in the database . so u take the filename from the database and attach the coresponding path where the file is located and display the image .
21 years ago
Sorry , I just enter the comments in the wrong window, they were answer to some other question so please do not bother .
What u can try out here is give the absolute path of the directory .
21 years ago
Well , what I feel here there is no way u can achieve this fuctionality without modifying the MultipartRequest.java file .
So what u can do is inside the constructor of MultipartRequest file u can check for the file type or ur condition on which u want to put ur file in the respective directory and make the call to its other constructor which takes 2 parameters and can set the direcory also .
21 years ago
Well Servlets work on a different mecanism . When a request is made to a particular servlet , the invoker method invokes the servlet . When the servlet is called , its init method is called only for the first time ,this is basically for initialzing the servlet parameters.
Once the Servlet method is initialized, All the request are dealt by either service method or
doGet,doPost method.
21 years ago