Java J2ME JSP J2EE Servlet Android
ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML
=====
DML operations like create, drop etc. and rollback/commit can not be performed in a SQL statement
Example:
=======
The most general case where this error occurs is calling a function as
SELECT myFunc(.. .. ..) FROM dual..
Something like this or the like, Where myFunc contains DML operations, rollback or commit statements.
Solution:
==========
You have to ensure that DML operations and rollback/commit operations must be autonomous instead of inside a query.
For the case described above you can execute the function myFunc as
var:=myFunc(.. .. ..);
Or redefine the function as
CREATE OR REPLACE function myFunc(.. .. ..) RETURN ..
AS
....
....
PRAGMA AUTONOMOUS_TRANSACTION
begin
.....
.....
.....
end;
Java By Example: Java Calendar day, month, week, year, hour getting, java.util.Calendar
Java By Example: Java Menue Example [ javax.swing.JMenu ]
Here is a very basic example of Java Menu[JMenue]
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class Menu extends JFrame{
public Menu()
{
super("Menu example");
JMenu file = new JMenu("File");
file.setMnemonic(’F’);
JMenuItem newItem = new JMenuItem("New");
newItem.setMnemonic(’N’);
file.add(newItem);
JMenuItem openItem = new JMenuItem("Open");
openItem.setMnemonic(’O’);
file.add(openItem);
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.setMnemonic(’x’);
file.add(exitItem);
//adding action listener to menu items
newItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.println("New is pressed");
}
}
);
openItem.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e)
{
System.out.println("Open is pressed");
}
}
);
exitItem.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e)
{
System.out.println("Exit is pressed");
}
}
);
JMenuBar bar = new JMenuBar();
setJMenuBar(bar);
bar.add(file);
getContentPane();
setSize(400, 400);
setVisible(true);
}
public static void main(String[] args)
{
Menu app = new Menu();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Java Vector to array or List to array
Vector friends = new Vector();
friends.add("Tuhin");
friends.add("Sumon");
friends.add("Habib");
friends.add("Shishir");
friends.add("Kiser");
friends.add("Zimi");
friends.add("Lizzie");
String arr[] = (String[]) friends.toArray(new String[0]);
System.out.println(Arrays.toString(arr));
List friendsList = new ArrayList();
friendsList.add("Tuhin");
friendsList.add("Sumon");
friendsList.add("Habib");
friendsList.add("Shishir");
friendsList.add("Kiser");
friendsList.add("Zimi");
friendsList.add("Lizzie");
arr = (String[]) friendsList.toArray(new String[0]);
System.out.println(Arrays.toString(arr));
If you execute the above code block. This will generate an output as follows..
[Tuhin, Sumon, Habib, Shishir, Kiser, Zimi, Lizzie]
[Tuhin, Sumon, Habib, Shishir, Kiser, Zimi, Lizzie]
Java Sorting Array, List
String friends[] = {"Tuhin", "Sumon","Habib","Shishir","Kiser","Zimi","Lizzie"};
System.out.println(Arrays.toString(friends));
List tempList = Arrays.asList(friends);
System.out.println(tempList);
Collections.sort(tempList);
System.out.println(tempList);
friends = (String[]) tempList.toArray(new String[0]);
System.out.println(Arrays.toString(friends));
This code block if execute will generate output like ...
[Tuhin, Sumon, Habib, Shishir, Kiser, Zimi, Lizzie]
[Tuhin, Sumon, Habib, Shishir, Kiser, Zimi, Lizzie]
[Habib, Kiser, Lizzie, Shishir, Sumon, Tuhin, Zimi]
[Habib, Kiser, Lizzie, Shishir, Sumon, Tuhin, Zimi]