Results 1 to 7 of 7
- 08-07-2007, 06:53 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 5
- Rep Power
- 0
problems with connecting to Oracle DB in NetBeans
Hi, guys,
I have a problem when trying to connect to Oracle DB in NetBeans. I've downloaded the Oracle Jar files like ocrs12.jar, ojdbc14.jar, ojdbc14dms.jar, orai18n.jar, and also I have built a new driver where I've added those four Jar files.
The problem is when I try to use this Oracle driver with the URL 'jdbc: oracle:thin:@//localhost:1527/sample', I always get a error message saying 'unable to get a connection,cannot establish a connection to jdbc: oracle:thin:@//localhost:1527/sample using oracle.jdbc.driver.OracleDriver(Io exception:The Network Adapter cannot establish the connection)'!!
Can anyone tell me what the problem is? Did I miss some Jar files or was the URL pattern incorrect? Please help, it's urgent!!!!!!!!! Many many thanksLast edited by m16k2002; 08-07-2007 at 06:57 AM.
- 08-08-2007, 01:07 AM #2
Senior Member
- Join Date
- Mar 2007
- Posts
- 134
- Rep Power
- 0
There will be a zip file classes12.zip in the files you downloaded add that to the classpath , it is better you renamce it as classes12.jar and add to class path
If you have done that check whether you oracle is up, I m bit doubtful about the connection string "oracle:thin:@//localhost:1527/sample" I think you dont need this "//" so it will be oracle:thin:@localhost:1527/sample, but Im not sure anyway I cant try it here as I dont have oracle right now then check the file tnsnames.ora and look for "sample" if everything is there then it has to work buddy :)
- 05-06-2008, 08:56 AM #3
Member
- Join Date
- May 2008
- Posts
- 2
- Rep Power
- 0
im getting network adapter error when i connect to oracle with netbean
im also getting this error [plz] help me?
- 05-06-2008, 09:37 AM #4
Member
- Join Date
- May 2008
- Posts
- 2
- Rep Power
- 0
oracle error
I have a problem when trying to connect to Oracle DB in NetBeans. I've downloaded the Oracle Jar files like ocrs12.jar, ojdbc14.jar, ojdbc14dms.jar, orai18n.jar, and also I have built a new driver where I've added those four Jar files.
The problem is when I try to use this Oracle driver with the URL 'jdbc: oracle:thin:@//localhost:1527/sample', I always get a error message saying 'unable to get a connection,cannot establish a connection to jdbc: oracle:thin:@//localhost:1527/sample using oracle.jdbc.driver.OracleDriver(Io exception:The Network Adapter cannot establish the connection)'!!
Can anyone tell me what the problem is? Did I miss some Jar files or was the URL pattern incorrect? Please help, it's urgent!!!!!!!!! Many many thanks
- 08-18-2008, 10:32 AM #5
Member
- Join Date
- Aug 2008
- Posts
- 1
- Rep Power
- 0
I have also problem with while connecting to oracle.When i select connect using oracle driver, then it keeps on connecting the database and do not given any response.Plz if you know then reply.Its urgent
- 03-25-2009, 10:11 AM #6
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
follow these steps u will easily get connected to any database..100 % assurance
[quote=vineet] see don't panic regarding the connectivity.follow these steps
if u have connected to the database and want to enter data into it.before that
Right click on your project -> Properties
Category Libraries
Compile tab
Add JAR / Folder("driver which can be odbc14.jar for oracle 10g" or "mysql-connector-java-5.0.6-bin.jar for Mysql")
now if u enter the data ..u can easily connect to it..for more assistance see the program below and do it accordingly..
"a program for inserting data into the database"
package javaapplication1;
import java.sql.*;
import javax.swing.JOptionPane;
/**
*
* @author Vineet
*/
public class NewJFrame extends javax.swing.JFrame {
/** Creates new form NewJFrame */
public NewJFrame() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jTextField1 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jTextField7 = new javax.swing.JTextField();
jTextField6 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
jLabel2.setText("ADDRESS ENTRY FORM");
jLabel1.setText("CMS");
jLabel3.setText("Entry ID:");
jLabel4.setText("Name:");
jLabel5.setText("Address:");
jLabel6.setText("City:");
jLabel7.setText("State:");
jLabel8.setText("Country:");
jLabel9.setText("Pincode:");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jButton1.setText("New Record");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton3.setText("Add Record");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton2.setText("Back");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.Gro upLayout.LEADING)
.add(0, 400, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(23, 23, 23)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(80, 80, 80)
.add(jLabel2))
.add(layout.createSequentialGroup()
.add(121, 121, 121)
.add(jLabel1))
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.TRAILING)
.add(jLabel3)
.add(jLabel4)
.add(jLabel5)
.add(jLabel6)
.add(jLabel7)
.add(jLabel8)
.add(jLabel9))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.LEADING)
.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 176, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
.add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 185, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, jTextField7)
.add(org.jdesktop.layout.GroupLayout.LEADING, jTextField6)
.add(org.jdesktop.layout.GroupLayout.LEADING, jTextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 136, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) )
.addContainerGap())
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(94, Short.MAX_VALUE)
.add(jButton1)
.add(18, 18, 18)
.add(jButton3)
.add(18, 18, 18)
.add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 81, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(5, 5, 5))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.Gro upLayout.LEADING)
.add(0, 315, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel1)
.add(18, 18, 18)
.add(jLabel2)
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.CENTER)
.add(jLabel3)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.BASELINE)
.add(jLabel4)
.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.BASELINE)
.add(jLabel5)
.add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.BASELINE)
.add(jLabel6)
.add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.BASELINE)
.add(jLabel7)
.add(jTextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.BASELINE)
.add(jLabel8)
.add(jTextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.BASELINE)
.add(jLabel9)
.add(jTextField7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(30, 30, 30)
.add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.BASELINE)
.add(jButton1)
.add(jButton2)
.add(jButton3))
.addContainerGap(org.jdesktop.layout.GroupLayout.D EFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jTextField1ActionPerformed(java.awt.event.ActionEv ent evt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");
jTextField6.setText("");
jTextField7.setText("");// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver Loaded");
// DriverManager.registerDriver("oracle.jdbc.driver.O racleDriver");
Connection con;
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/employee","root","hr");
System.out.println("Database Connected");
PreparedStatement stat2=con.prepareStatement("insert into CMS (ENTRY_ID,NAME,Address,City,State,Country,Pincode) values(?,?,?,?,?,?,?)");
stat2.setString(1,jTextField1.getText());
stat2.setString(2,jTextField2.getText());
stat2.setString(3,jTextField3.getText());
stat2.setString(4,jTextField4.getText());
stat2.setString(5,jTextField5.getText());
stat2.setString(6,jTextField6.getText());
stat2.setString(7,jTextField7.getText());
stat2.executeUpdate();
JOptionPane.showMessageDialog(rootPane, new String("Address details have been added!!"));
}
catch(SQLException exception1)
{
System.out.println(exception1);
}
catch(Exception exception)
{
JOptionPane.showMessageDialog(rootPane,new String("Error encountered while entering data in the database: "+exception));
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
this.hide();// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
// End of variables declaration
---hope it will help all of u in getting the connectivity---:)Last edited by vinuvineet; 03-25-2009 at 10:16 AM.
- 03-25-2009, 10:14 AM #7
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Problems with NetBeans
By gabriel in forum NetBeansReplies: 2Last Post: 11-07-2007, 09:49 PM -
Problems updating blob columns on Oracle 9
By ljustiniano in forum JDBCReplies: 0Last Post: 08-14-2007, 06:17 PM -
Error While connecting to Oracle thru JAVA
By javaneed in forum Advanced JavaReplies: 1Last Post: 08-11-2007, 10:05 PM -
problems with connecting to Oracle DB in NetBeans
By m16k2002 in forum NetBeansReplies: 0Last Post: 08-07-2007, 07:01 AM -
Problems to install NetBeans
By fred in forum NetBeansReplies: 1Last Post: 08-02-2007, 05:58 PM


LinkBack URL
About LinkBacks


Bookmarks