Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Connectivity issue in SQL developer.

2616736Feb 20 2014 — edited Feb 20 2014

Hi,

I have installed SQL developer 64bit on windows 7. I am trying to connect to a 11g Rel 2 database. But connection failed with the below error:

Status: Failure - Test failed: IO Error: The Network Adapter could not establish the connection.

Appreciate your help on configuring SQL developer tool as i am new to oracle.

Thanks in Advance.

Comments

800346
Try using a PrintRequestAttributeSet. Example:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.*;
import java.text.MessageFormat;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.swing.*;

public class PrintDemo extends JFrame {

    private JButton btPrint;
    private JCheckBox cbPortrait;
    private JToolBar toolbar;
    private JTextArea textarea;
    static private PrintRequestAttributeSet attr;

    public PrintDemo() {
        super("PrintDemo");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setSize(600, 300);
        setLocationRelativeTo(null);
        textarea = new JTextArea();
        toolbar = new JToolBar();
        btPrint = new JButton("Print");
        cbPortrait = new JCheckBox("Portrait");
        textarea.setText("print(textarea.getPrintable(new MessageFormat(" +
                "\"PrintDemo\"), null), cbPortrait.isSelected());");
        getContentPane().add(new JScrollPane(textarea), BorderLayout.CENTER);
        toolbar.add(btPrint);
        cbPortrait.setSelected(true);
        toolbar.add(cbPortrait);
        getContentPane().add(toolbar, BorderLayout.PAGE_START);
        btPrint.addActionListener(new ActionListener() {

            public void actionPerformed(final ActionEvent evt) {
                print(textarea.getPrintable(new MessageFormat("PrintDemo"), null), cbPortrait.isSelected());
            }
        });
        cbPortrait.addActionListener(new ActionListener() {

            public void actionPerformed(final ActionEvent evt) {
                attr = null;
            }
        });
    }

    static public void print(final Printable printable) {
        print(printable, true);
    }

    static public void print(final Printable printable, final boolean portrait) {
        print(printable, portrait, new Insets(10, 10, 10, 10));
    }

    static public void print(final Printable printable, final boolean portrait, final Insets insets) {
        PrinterJob pjob = PrinterJob.getPrinterJob();
        pjob.setPrintable(printable);
        // create an attribute set to store attributes from the print dialog
        if (attr == null) {
            attr = new HashPrintRequestAttributeSet();
            float leftMargin = insets.left;
            float rightMargin = insets.right;
            float topMargin = insets.top;
            float bottomMargin = insets.bottom;
            if (portrait) {
                attr.add(OrientationRequested.PORTRAIT);
            } else {
                attr.add(OrientationRequested.LANDSCAPE);
                leftMargin = insets.top;
                rightMargin = insets.bottom;
                topMargin = insets.right;
                bottomMargin = insets.left;
            }
            attr.add(MediaSizeName.ISO_A4);
            MediaSize mediaSize = MediaSize.ISO.A4;
            float mediaWidth = mediaSize.getX(Size2DSyntax.MM);
            float mediaHeight = mediaSize.getY(Size2DSyntax.MM);
            attr.add(new MediaPrintableArea(
                    leftMargin, topMargin,
                    (mediaWidth - leftMargin - rightMargin),
                    (mediaHeight - topMargin - bottomMargin), Size2DSyntax.MM));
        }
//        if (pjob.printDialog(attr)) {
            try {
                pjob.print(attr);
            } catch (PrinterException ex) {
                ex.printStackTrace();
            }
//        }
    }

    public static void main(final String args[]) {
        EventQueue.invokeLater(new Runnable() {

            public void run() {
                new PrintDemo().setVisible(true);
            }
        });
    }
}
darrylburke
Note: This thread was originally posted in the [New To Java|http://forums.sun.com/forum.jspa?forumID=54] forum, but moved to this forum for closer topic alignment.
843807
Dear Mr. Andre Uhres,

Thanks for your response.

Though I was expecting a much shorter solution, I will check based on your inputs and keep you all posted of the outcome.

Regards,
Sudheendran T L
843807
Dear Andre,
Dear All,

I am trying to use the print method of the JTextComponent class. (Ref [http://java.sun.com/docs/books/tutorial/uiswing/misc/printtext.html|http://java.sun.com/docs/books/tutorial/uiswing/misc/printtext.html]
).

I want to use the following method especially:
boolean complete = textComponent.print(MessageFormat headerFormat,
          		               MessageFormat footerFormat, 
                                               boolean showPrintDialog,
                                               PrintService service
                                               PrintRequestAttributeSet attributes,
                                               boolean interactive);
I have already saved the pageFormat using the pageDialog method of PrinterJob. My question is how do I translate ALL the content of the pageFormat into the PrintRequestAttributeSet? For example, I have used the orientation from the PageFormat saved to set the apporpriate attribute. See below code. How do I set other attributes like the Paper size and margins?

PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
if ( pageFormat.getOrientation() == PageFormat.LANDSCAPE ){
    pras.add(OrientationRequested.LANDSCAPE);
} else {
    pras.add(OrientationRequested.PORTRAIT);
}
Will appreciate any help.

Regards,
Sudheendran T L
800346
The sample code that I posted above looks a bit complicated only because the page setup is done programmatically. If you want to display the standard page dialog (which might however look complicated to the user), you simply pass the "PrintRequestAttributeSet" that you also use for printing:
pjob.pageDialog(attr);
textComponent.print(null, null, true, pjob.getPrintService(), attr, true);
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 20 2014
Added on Feb 20 2014
1 comment
90,138 views