need help in debugging

This is part of my code. The 2 functions private void jButtonMouseClicked

are similar but only the last one has syntax error: class, interface, or enum expected. How to fix it?Thx!

import java.io.*;

import java.sql.*;

import oracle.jdbc.driver.*;

import oracle.sql.*;

import java.awt.*;

import javax.swing.*;

public class JFrame extends javax.swing.JFrame {

public JFrame() {

initComponents();

}

private void jButton14MouseClicked(java.awt.event.MouseEvent evt) {

String sql1;

ResultSet rs1= stmt.executeQuery(sql1);

while (rs1.next())

{

jTextArea1=JTextArea(rs1.getString(1) + " " + rs1.getString(2) + " " + rs1.getInt(3));

}

jScrollPane1=JScrollPane(jtextArea1);

}

}

private void jButton13MouseClicked(java.awt.event.MouseEvent evt) {

String sql2;

ResultSet rs2 = stmt.executeQuery(sql2);

while (rs2.next())

{

jTextArea1=JTextArea(rs2.getString(1) + " " + rs2.getString(2) + " " + rs2.getInt(3));

jScrollPane1=JScrollPane(jtextArea1);

}

}

[1134 byte] By [CuriousDummya] at [2007-11-27 2:18:34]
# 1

When you post code, please use[code] and [/code] tags as described in [url=http://forum.java.sun.com/help.jspa?sec=formatting ]Formatting tips[/url] on the message entry page. It makes it much easier to read.

If you had a proper indentation you had noticed that you closed the class declaration after jButton14MouseClicked.

PhHeina at 2007-7-12 2:18:05 > top of Java-index,Java Essentials,Java Programming...
# 2

I wonder about the second closing } at the "end" of jButton14MouseClicked.

But, really it's hard to tell. If you post code, use the "code" tags (http://forum.java.sun.com/help.jspa?sec=formatting) so that it's readable. And if there is a compiler message it's a good idea to copy, paste and post the exact (and entire) message and indicate to which line of your code the message refers.

pbrockway2a at 2007-7-12 2:18:05 > top of Java-index,Java Essentials,Java Programming...
# 3

Thx! That is fixed. Now I have another problem.

This is part of my code. It has 5 syntax errors.I have no idea to fix them. What's wrong?

The 4 lines started from String url, username, password; have errors.

Compiling 1 source file to .java:744: <identifier> expected

username = "xx";

^

745: <identifier> expected

password = "xx";

^

746: <identifier> expected

url="jdbc:oracle:thin:@localhost:1521:XE";

748: <identifier> expected

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

^

748: illegal start of type

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

^

5 errors

import java.io.*;

import java.sql.*;

import oracle.jdbc.driver.*;

import oracle.sql.*;

import java.awt.*;

import javax.swing.*;

public class JFrame extends javax.swing.JFrame {

/** Creates new form JFrame */

public JFrame() {

initComponents();

}

String url, username, password;

username = "xx";

password = "xx";

url="jdbc:oracle:thin:@localhost:1521:XE";

// Connection

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new JFrame().setVisible(true);

}

});

}

CuriousDummya at 2007-7-12 2:18:05 > top of Java-index,Java Essentials,Java Programming...
# 4
why dont u tryString url="jdbc:oracle:thin:@localhost:1521:XE";String username="xx";String password="xx";
ayberka at 2007-7-12 2:18:05 > top of Java-index,Java Essentials,Java Programming...
# 5
Thx! 2 errors left in the line:DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
CuriousDummya at 2007-7-12 2:18:05 > top of Java-index,Java Essentials,Java Programming...
# 6
what are they could you write plzayberk cansever
ayberka at 2007-7-12 2:18:06 > top of Java-index,Java Essentials,Java Programming...
# 7
748: <identifier> expectedDriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());^748: illegal start of typeDriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());^
CuriousDummya at 2007-7-12 2:18:06 > top of Java-index,Java Essentials,Java Programming...
# 8
i guess you should use this kind of code if u want to connect the databaseClass.forName ("oracle.jdbc.driver.OracleDriver").newInstance();Connection conn = DriverManager.getConnection(connectionURL, userID,userPassword);ayberk cansever
ayberka at 2007-7-12 2:18:06 > top of Java-index,Java Essentials,Java Programming...
# 9

Thx but It has the same errors.

Compiling 1 source file to .java:

750: <identifier> expected

Class.forName ("oracle.jdbc.driver.OracleDriver").newInstance();

750: illegal start of type

Class.forName ("oracle.jdbc.driver.OracleDriver").newInstance();

2 errors

CuriousDummya at 2007-7-12 2:18:06 > top of Java-index,Java Essentials,Java Programming...
# 10

> i guess you should use this kind of code if u want to

> connect the database

>

> > Class.forName

> ("oracle.jdbc.driver.OracleDriver").newInstance();

> Connection conn =

> DriverManager.getConnection(connectionURL,

> userID,userPassword);

>

>

> ayberk cansever

why do you need the newInstance() ?

georgemca at 2007-7-12 2:18:06 > top of Java-index,Java Essentials,Java Programming...