the program works fine but it gives this java uses or overrides a deprecated API error after i compile the code is below it is a program that uses sql the data base is northwind.I hope you could help me its a project so any help would be welcomed.

import java.sql.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.io.*;
import java.util.Vector;
public class jdbc3 {
public static void main (String args[]){
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
pencere p1 = new pencere();
p1.setVisible (true);
p1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
}
}
 
class pencere extends JFrame{
JTextArea sonuc;
JScrollPane scsonuc;
Container cont;
Toolkit kit;
Dimension dim;
int sw,sh; 
ust ust1;
giris giris1;
Statement stat;
ResultSet rset;
 
 
public pencere(){
setTitle("JDBC Version 1.0");
cont = this.getContentPane();
kit = this.getToolkit();
dim = kit.getScreenSize();
sw =dim.width;sh=dim.height;
this.setSize(sw-100,sh-100);
this.setLocation(50,50); 
 
giris1= new giris(this);//JDialog ornegi
 
ust1=new ust(this);//panel ornegi
sonuc= new JTextArea();
scsonuc=new JScrollPane(sonuc);
 
cont.add(ust1,BorderLayout.NORTH);
cont.add(scsonuc,BorderLayout.CENTER);
 
	}
public void getir(){//statement ve ilk resultset
 
try {
Statement stat = giris1.con.createStatement();
this.ust1.tabloz();//tablo isimlerini alan metot 
 
}
catch (Exception e){System.out.print("Error");
	}
giris1.setVisible(false);//dialog gizlenir
}	
}
class ust extends JPanel{//ust kisim
JComboBox tablo;
JList sutun;
JScrollPane scp,sctext;
JTextArea sorgu;
JButton submit,reset,login;
Vector sutunlar=new Vector();
pencere pen;//ana pencere ile iliski kuruluyor
 
public ust(pencere vpen){
this.pen = vpen;//iliski kuruldu
this.setLayout(new FlowLayout());
 
 
 
tablo = new JComboBox();
tablo.addItemListener(new ItemListener(){//sutun isimleri geliyor
	public void itemStateChanged(ItemEvent ie){
	 String tablomuz=tablo.getSelectedItem().toString();
	 String sql="select * from "+tablomuz;
	 sutunlar.clear();//ilk önce temizlik
	 try{
	 Statement stat2=pen.giris1.con.createStatement();
	 ResultSet sutset = stat2.executeQuery(sql);
	 ResultSetMetaData rsmd = sutset.getMetaData();
 
	 for (int i=1;i<=rsmd.getColumnCount();++i){
	 sutunlar.add(rsmd.getColumnName(i));
	 }
 
	 sutun.setListData(sutunlar);//sutun isimleri eklendi
 
	 stat2.close();
 
	 }catch (Exception e){System.out.println("Invalid Column");}
 
	 }
 
	});
 
sutun = new JList(sutunlar);
sutun.setFixedCellWidth(120);
sutun.setVisibleRowCount(3);
sutun.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
sutun.addListSelectionListener(new ListSelectionListener(){//sql ifadesi hazirlaniyor
	public void valueChanged(ListSelectionEvent le){
	 Object sutunlar[]=sutun.getSelectedValues();
	 String sutunlarim=""; 
	 for(int i=0;i<sutunlar.length;i++){
	 String sutunisim=sutunlar[i].toString();
	 if(sutunisim.indexOf(" ")>0)
	 sutunisim="["+sutunisim+"]";
	 sutunlarim+=sutunisim;
	 if(i!=sutunlar.length-1)
	 sutunlarim+=" , ";
	 }
	 sorgu.setText("select "+ sutunlarim +" from "
		+tablo.getSelectedItem().toString()); 
 
	 }
 
	});
scp = new JScrollPane(sutun); 
sorgu = new JTextArea(3,15);
sorgu.setLineWrap(true);
sctext=new JScrollPane(sorgu);
submit = new JButton("Submit");
submit.addActionListener(new ActionListener(){//sougulama 
	public void actionPerformed(ActionEvent ae){
	 String sqlim=sorgu.getText();
	 pen.sonuc.setText("");
	 try{
	 Statement stat3=pen.giris1.con.createStatement();
	 ResultSet sorguset=stat3.executeQuery(sqlim);
	 ResultSetMetaData sorgursmd=sorguset.getMetaData();
	 int sutunsayi=sorgursmd.getColumnCount();
	 for(int i=1;i<=sutunsayi;i++){
	 pen.sonuc.append(sorgursmd.getColumnName(i)+"\t");
	 }
	 pen.sonuc.append("\n");
	 for(int i=1;i<=sutunsayi;i++){
	 pen.sonuc.append("-------------\t");
	 }
	 pen.sonuc.append("\n");	 
	 while(sorguset.next()){
	 for(int i=1;i<=sutunsayi;i++){
	 pen.sonuc.append(sorguset.getString(i)+"\t");
	 }
	 pen.sonuc.append("\n");
 
	 }
	 }catch(Exception e){System.out.println("OLMAZZZZ");}
	 }
	});
reset = new JButton("Reset");//temizleme
reset.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent ae){
	 sorgu.setText("");
	 pen.sonuc.setText("");
	 }
 
	});
login = new JButton("Login");
login.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent ae)
	{
	 pen.giris1.setVisible(true);
	 }
	});
add(login);add(tablo);add(scp);add(sctext);add(submit);add(reset);
 
 
 
}
 
public void tabloz(){//tablolar bulunuyor
try{
DatabaseMetaData dbmd = pen.giris1.con.getMetaData();
		 ResultSet tabloset = dbmd.getTables(null, null, null ,null);
		 while(tabloset.next()){ 
		 String tablename = tabloset.getString("TABLE_NAME");
		 String tabletype = tabloset.getString("TABLE_TYPE");
		 if(tabletype.equals("TABLE"))
		 tablo.addItem(tablename);
		 }
		 tabloset.close();
 
		 }
catch (Exception e){System.out.println("Invalid Table");}
}
 
 
}
 
 
class giris extends JDialog{
JLabel login,password;
JTextField log; 
JPasswordField pass;
JButton enter,cancel;
Container dicont;
pencere pen;
Connection con;
 
public giris(pencere vpen){
this.pen = vpen;
this.setSize(250,150);
this.setTitle("Enter Login and Password");
 
login = new JLabel("Login");
password = new JLabel("Password");
log = new JTextField(12);
pass = new JPasswordField(12);
 
 
enter = new JButton("Enter");
enter.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent ae)
	{
	try{ 
	 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	 con= DriverManager.getConnection("jdbc:odbc:John",log.getText()
	 ,pass.getText());
	 pen.getir();
	}
catch (Exception e){JOptionPane.showMessageDialog(pen,
		 "Invalid Login",
		 "Warning",
		 JOptionPane.WARNING_MESSAGE);
		giris.this.setVisible(true);
	}
	 }
	});
 
 
cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent ae)
	{
	giris.this.setVisible(false);
	 }
	});
dicont= this.getContentPane();
dicont.setLayout(new GridLayout(3,2));
dicont.add(login);dicont.add(log);dicont.add(password);dicont.add(pass);
dicont.add(enter);dicont.add(cancel);
this.setLocationRelativeTo(pen);
 
}
 
}

Hello johnroach1985,
The error deprecated API is nothing to worry about. Your codes will compile and run fine. API stands for application programming interface. This simply means the way you are accessing the behaviors of your classes or objects.

Thank you for replying Benderson,
So it is not important great hope the teacher gives full marks.Thank you again.

Uhh... it's generally a bad idea to leave the deprecated statements in. Usage of functions marked as deprecated is generally discouraged because usage of that function in that way has some undesired effect either semantic or run-tine. Deprecated functions are not guaranteed to work in the next version of the JDK. If I were your teacher I'd definitely not want deprecated functions.

What you should do is run javac with the -deprecated flag. This will alert you as to which line contains the deprecated statement. Then you may look in the Javadocs to find the function and its associated replacement function.

If you told me what's deprecated I may know off-hand what it was replaced by. Maybe you could make a special note in your source code that you replaced your deprecated function with the new one---Maybe even score a few extra points ;-)


Ed

Thank you for replying Benderson,
So it is not important great hope the teacher gives full marks.Thank you again.

i am sorry to ask but how do you run javac with the -deprecated flag is that done in ms-dos??i use jcreator pro any help would be welcomed.I tried to use jcreators help but i couldn't find it in its help files.
Thank you again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.