Pradeep

Ranch Hand
+ Follow
since Sep 19, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Pradeep

Hi All,

I want to design birthday calendar in jsp,anybody have idea of same,please share with me

Thanks in advance

Pradeep
17 years ago
JSP
Hi Bear,

I am using apache commmon file upload package for that requires portlet-api.jar file. Do you know where would i get free download of same.

thanks
Pradeep
17 years ago
Hi all,

I have to upload multiple files using servlet,i dont want to use apache common file upload package.

Thanks in advance.
17 years ago
hi
i want to do table sorting based on column

i am getting following error :




Sorting ...
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.cisco.dca.TableSorter.checkModel(TableSorter.java:146)
at com.cisco.dca.TableSorter.sort(TableSorter.java:152)
at com.cisco.dca.TableSorter.sortByColumn(TableSorter.java:201)
at com.cisco.dca.TableHeaderSorter.mouseClicked(TableSorter.java:231)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:212)
at java.awt.Component.processMouseEvent(Component.java:5504)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5266)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3968)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3901)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1778)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)



my java code is as follows

public class MarkSuspiciousBaggage extends javax.swing.JPanel {

{
//Set Look & Feel
try {
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch(Exception e) {
e.printStackTrace();
}
}

private JScrollPane scroll;
private JTable table;
private JButton jButton1;
private JLabel details;
private JLabel header;
private JButton locateSuspiciousLuggage;
public static MarkSuspiciousBaggage markSuspiciousBaggageInstance = null;

class ButtonListener implements ActionListener {
JTable tab ;
ButtonListener(JTable table)
{
System.out.print("table is " + table);
this.tab = table;
}
public void actionPerformed(ActionEvent e) {
System.out.println("inside actionPerformed " + e.getActionCommand() + " source " + e.getSource());
if(e.getActionCommand().equals("Clear Tag"))
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try {
DBUtils.loadDriver();
conn = DBUtils.fetchConnection();
System.out.println("before selected");
System.out.println("value is " + tab.getValueAt(0,0 ));

System.out.println("value of the ======= " + tab.getValueAt(tab.getSelectedRow(), 0));
String query = "update DCA_Baggage_Info set ISSuspicious ='N' where TagID = '"+tab.getValueAt(tab.getSelectedRow(), 0)+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
System.out.println("finshed");
}catch(Exception SQLexp1){
}

//System.out.println("value of the ======= " + tab.getValueAt(tab.getSelectedRow(), 6));


}
else
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try {
DBUtils.loadDriver();
conn = DBUtils.fetchConnection();
System.out.println("before selected");
System.out.println("value is " + tab.getValueAt(0,0 ));

System.out.println("value of the ======= " + tab.getValueAt(tab.getSelectedRow(), 0));
String query = "update DCA_Baggage_Info set ISSuspicious ='Y' where TagID = '"+tab.getValueAt(tab.getSelectedRow(), 0)+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
System.out.println("finshed");
}catch(Exception SQLexp1){
}
}

}

}
/**
* Auto-generated main method to display this
* JPanel inside a new JFrame.
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.getContentPane().add(new MarkSuspiciousBaggage());
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);

}

private MarkSuspiciousBaggage() {
super();
initGUI();
marksuspiciousBaggagePopulate();
}

public static MarkSuspiciousBaggage getInstance() {

if (markSuspiciousBaggageInstance == null) {
System.out.println("I am here in mark");
markSuspiciousBaggageInstance = new MarkSuspiciousBaggage();
return markSuspiciousBaggageInstance;
} else {
return markSuspiciousBaggageInstance;
}
}

private void initGUI() {
try {
GridBagLayout thisLayout = new GridBagLayout();
thisLayout.rowWeights = new double[] {0.1, 0.1, 0.1};
thisLayout.rowHeights = new int[] {7, 7, 7};
thisLayout.columnWeights = new double[] {0.1};
thisLayout.columnWidths = new int[] {7};
this.setLayout(thisLayout);
this.setPreferredSize(new java.awt.Dimension(772, 531));

scroll = new JScrollPane();
this.add(scroll, new GridBagConstraints(0, 0, 1, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(60, 5, 50, 5), 0, 0));
scroll
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scroll
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scroll.setPreferredSize(new Dimension(200, 1000));
scroll.setBorder(new LineBorder(
new java.awt.Color(0, 0, 0),
1,
false));
scroll.setName("BagageSearch_JS_ScrollPane");
scroll.setSize(new Dimension(1000, 1000));

locateSuspiciousLuggage = new JButton();
this.add(locateSuspiciousLuggage, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(55, 10, 10, 0), 0, 0));
locateSuspiciousLuggage.setText("Tag Suspicious");

header = new JLabel();
this.add(header, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
header.setText("Mark Suspicious Luggage");
header.setSize(400, 20);
header.setFont(new java.awt.Font("Tahoma",1,14));
header.setForeground(new java.awt.Color(128,0,0));
header.setHorizontalAlignment(SwingConstants.CENTER);

details = new JLabel();
this.add(details, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 55, 0), 0, 0));
details.setText("List of all the Tagged Baggage's:");

jButton1 = new JButton();
this.add(jButton1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(55, 10, 10, 0), 0, 0));
jButton1.setText("Clear Tag");

} catch (Exception e) {
e.printStackTrace();
}
}
public void marksuspiciousBaggagePopulate() {
System.out.println("***********************************************************");
System.out.println("Within populate ########### ");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try {
DBUtils.loadDriver();
conn = DBUtils.fetchConnection();
String countquery = "select count(*) from DCA_PASSENGER_INFO";
int rowcount = 0;
stmt = conn.createStatement();
rs = stmt.executeQuery(countquery);
while (rs.next()){
rowcount = rs.getInt(1);
}

stmt.close();
rs.close();

//String queryString = "select PassengerID,TagID,PASSENGER_NAME,FLIGHT_NO,TICKET_NUMBER,SEAT_NUMBER from DCA_PASSENGER_INFO";
String queryString = "SELECT bi.TagID, fd.*, pi.* FROM DCA_Baggage_Info bi,DCA_PASSENGER_INFO pi,DCA_Flight_Details fd WHERE pi.PassengerID=bi.Passenger_Id and pi.FLIGHT_NO = fd.FLIGHT_NO";
stmt = conn.createStatement();
System.out.println("Query Details >>>>> " + queryString);
rs = stmt.executeQuery(queryString);

int li_row = 0;

Object [][] addVal = new Object[rowcount][7];
Object baggageid = null;
Object flightnumber = null;
Object ticketnumber = null;
Object passengername = null;
Object airlinecode = null;
Object dateofjourney = null;
ButtonGroup group1 = new ButtonGroup();
while (rs.next()) {
baggageid = rs.getString("TagID");
flightnumber = rs.getString("FLIGHT_NO");
ticketnumber = rs.getString("TICKET_NUMBER");
passengername = rs.getString("PASSENGER_NAME");
airlinecode = rs.getString("AirLine_Code");
dateofjourney = rs.getString("departure_time");

addVal[li_row][0] = baggageid;
addVal[li_row][1] = flightnumber;
addVal[li_row][2] = ticketnumber;
addVal[li_row][3] = passengername;
addVal[li_row][4] = airlinecode;
addVal[li_row][5] = dateofjourney;
JRadioButton radioButton = new JRadioButton();
group1.add(radioButton);
addVal[li_row][6] = radioButton;
li_row ++;
}
DefaultTableModel dm = new DefaultTableModel();
dm.setDataVector(addVal, new Object[] { "BaggageID", "Flight_No", "Ticket_No", "Passanger Name", "AIRLINE CODE", "Date_of_Journey", "Select" });
JTable table = new JTable(dm) {

public boolean isCellEditable(int rowIndex, int vColIndex) {
System.out.println(vColIndex);
if(vColIndex == 6)
return true;
else
return false;
}

public void tableChanged(TableModelEvent e) {
super.tableChanged(e);
System.out.println("inside the event trigred");
repaint();
}
};

TableSorter sortedModel = new TableSorter();
sortedModel.addTableModelListener(table);
// table.setModel(dm);
System.out.println("in table sorting");
TableHeaderSorter.install(sortedModel, table);
System.out.println("i am in table sorter");
table.getTableHeader().setBounds(0, 0, 455, 21);
table.setColumnSelectionAllowed(false);
table.setRowSelectionAllowed(false);
table.setCellSelectionEnabled(false);
table.getColumn("Select").setCellRenderer(
new RadioButtonRenderer());
table.getColumn("Select").setCellEditor(
new RadioButtonEditor(new JCheckBox()));
scroll.setViewportView(table);

ButtonListener b1 = new ButtonListener(table);
locateSuspiciousLuggage.addActionListener(b1);
jButton1.addActionListener(new ButtonListener(table));
System.out.println("End of populate method");

}
catch(Exception SQLexp){
SQLexp.printStackTrace();
System.out.println("Exception while interacting with the database " + SQLexp);
} finally {
DBUtils.closeConnection(conn);
try {
stmt.close();
rs.close();
} catch(Exception e) {
e.printStackTrace();
}

}

}



}
17 years ago
thanks

i solved that error

now i am getting following error when try to insert big size image


ORA-01461: can bind a LONG value only for insert into a LONG column
17 years ago
Hi,

I am inserting image in db, its ok with small size image but when large size image, it shows following error


ORA-01461: can bind a LONG value only for insert into a LONG column


table and code details :


create table MyPictures1 (
id INT PRIMARY KEY,
name VARCHAR(11),
myphoto CLOB


java code :


public class InsertPictureToOracle {
public static void main(String[] args) throws Exception, IOException, SQLException {
Connection conn = null;
DBUtils.loadDriver();
conn = DBUtils.fetchConnection();
FileInputStream fis = null;
PreparedStatement ps = null;
Statement stmt = null;
String INSERT_PICTURE = "insert into MyPictures values(?,?,?)";
System.out.println("i am here");
try {
conn.setAutoCommit(false);
File file = new File("com/dca/Banner.jpg");
fis = new FileInputStream(file);
ps = conn.prepareStatement(INSERT_PICTURE);
ps.setString(1, "0013");
//ps.setString(2, "gajanan");
ps.setString(2, file.getName());
ps.setBinaryStream(3, fis, (int) file.length());
//ps.setBinaryStream(3, fis, fis.available());
System.out.println("i am there");
int i=ps.executeUpdate();
if(i!=0)
{
System.out.println("image has been inserted");
}
else
{
System.out.println("image is not inserted");
}
conn.commit();
//System.out.println("insert image successfully");
ResultSet rs =stmt.executeQuery("select myphoto from MyPictures where id=001");
byte[] imgbytes=null;
if(rs.next()) {
imgbytes=rs.getBytes(10);
System.out.println("image value "+imgbytes);
}
rs.close();
System.out.println("populate image successfully");
} catch(Exception SQLexp){
SQLexp.printStackTrace();
System.out.println("Exception while interacting with the database " + SQLexp);
} finally {
DBUtils.closeConnection(conn);
try {
stmt.close();
} catch(Exception e) {
e.printStackTrace();
}

}
// InsertPictureToOracle picture = new InsertPictureToOracle();
// picture.imagePopulate();
}
public void imagePopulate()
{
System.out.println("***********************************************************");
System.out.println("Within Imagepopulate ########### ");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try {
DBUtils.loadDriver();
conn = DBUtils.fetchConnection();
String query = "select from Mypictures where id=1";
byte[] imgbytes=null;
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
while (rs.next()){
imgbytes=rs.getBytes(1);

// int value = rs.getInt(1);
//String myname = rs.getString(2);
//System.out.println(value);
}

stmt.close();
rs.close();
System.out.println("populate successfully");
}catch(Exception SQLexp){
SQLexp.printStackTrace();
System.out.println("Exception while interacting with the database " + SQLexp);
} finally {
DBUtils.closeConnection(conn);
try {
stmt.close();
rs.close();
} catch(Exception e) {
e.printStackTrace();
}

}

}
}
17 years ago
i got error in following line


ps.executeUpdate();
17 years ago
Hi,

I am going to insert/retrieve image in database

table:

create table MyPictures (
id INT PRIMARY KEY,
name VARCHAR(11),
myphoto BLOB
)

my java class

public class InsertPictureToOracle {
public static void main(String[] args) throws Exception, IOException, SQLException {
Connection conn = null;
DBUtils.loadDriver();
conn = DBUtils.fetchConnection();
FileInputStream fis = null;
PreparedStatement ps = null;
Statement stmt = null;
String INSERT_PICTURE = "insert into MyPictures(id, name, myphoto) values (?, ?, ?)";
System.out.println("i am here");
try {
conn.setAutoCommit(false);
File file = new File("com/cisco/wipro/dca/GAJANANBABA.jpg");
fis = new FileInputStream(file);
ps = conn.prepareStatement(INSERT_PICTURE);
ps.setString(1, "001");
ps.setString(2, "psm");
ps.setBinaryStream(3, fis, (int) file.length());
System.out.println("i am there");
ps.executeUpdate();

conn.commit();
System.out.println("insert image successfully");
ResultSet rs =stmt.executeQuery("select myphoto from MyPictures where id=001");
byte[] imgbytes=null;
if(rs.next()) {
imgbytes=rs.getBytes(1);
}
rs.close();
System.out.println("populate image successfully");
} catch(Exception SQLexp){
SQLexp.printStackTrace();
System.out.println("Exception while interacting with the database " + SQLexp);
} finally {
DBUtils.closeConnection(conn);
try {
stmt.close();
} catch(Exception e) {
e.printStackTrace();
}

}

i am getting following error:

ORA-01460: unimplemented or unreasonable conversion requested

please help
17 years ago
hi

I want to retrieve data from database in java swing.

how can do that

I have 4 columns in java swing which would fetch values from database

thanks in advance
17 years ago
HI

I want to show data in table format in jsp. I am one calling servlet in jsp which retriving data from database.
17 years ago
JSP
Hi Rahul,

I think, spend first five years in technical side then only think about MBA.
17 years ago
Hi,

I have to prepare for keytool,jks,self signed certifiate.......

can anyone send me link where I will get same.

Thanks in advance
17 years ago
Hi,

You can go through following link :

www.roseindia.net
17 years ago
JSP