java uses or overrides a deprecated API??

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2004
Posts: 129
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

java uses or overrides a deprecated API??

 
0
  #1
Sep 11th, 2004
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.

  1. import java.sql.*;
  2. import java.awt.*;
  3. import javax.swing.*;
  4. import javax.swing.event.*;
  5. import java.awt.event.*;
  6. import java.io.*;
  7. import java.util.Vector;
  8. public class jdbc3 {
  9. public static void main (String args[]){
  10. JFrame.setDefaultLookAndFeelDecorated(true);
  11. JDialog.setDefaultLookAndFeelDecorated(true);
  12. pencere p1 = new pencere();
  13. p1.setVisible (true);
  14. p1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  15.  
  16. }
  17. }
  18.  
  19. class pencere extends JFrame{
  20. JTextArea sonuc;
  21. JScrollPane scsonuc;
  22. Container cont;
  23. Toolkit kit;
  24. Dimension dim;
  25. int sw,sh;
  26. ust ust1;
  27. giris giris1;
  28. Statement stat;
  29. ResultSet rset;
  30.  
  31.  
  32. public pencere(){
  33. setTitle("JDBC Version 1.0");
  34. cont = this.getContentPane();
  35. kit = this.getToolkit();
  36. dim = kit.getScreenSize();
  37. sw =dim.width;sh=dim.height;
  38. this.setSize(sw-100,sh-100);
  39. this.setLocation(50,50);
  40.  
  41. giris1= new giris(this);//JDialog ornegi
  42.  
  43. ust1=new ust(this);//panel ornegi
  44. sonuc= new JTextArea();
  45. scsonuc=new JScrollPane(sonuc);
  46.  
  47. cont.add(ust1,BorderLayout.NORTH);
  48. cont.add(scsonuc,BorderLayout.CENTER);
  49.  
  50. }
  51. public void getir(){//statement ve ilk resultset
  52.  
  53. try {
  54. Statement stat = giris1.con.createStatement();
  55. this.ust1.tabloz();//tablo isimlerini alan metot
  56.  
  57. }
  58. catch (Exception e){System.out.print("Error");
  59. }
  60. giris1.setVisible(false);//dialog gizlenir
  61. }
  62. }
  63. class ust extends JPanel{//ust kisim
  64. JComboBox tablo;
  65. JList sutun;
  66. JScrollPane scp,sctext;
  67. JTextArea sorgu;
  68. JButton submit,reset,login;
  69. Vector sutunlar=new Vector();
  70. pencere pen;//ana pencere ile iliski kuruluyor
  71.  
  72. public ust(pencere vpen){
  73. this.pen = vpen;//iliski kuruldu
  74. this.setLayout(new FlowLayout());
  75.  
  76.  
  77.  
  78. tablo = new JComboBox();
  79. tablo.addItemListener(new ItemListener(){//sutun isimleri geliyor
  80. public void itemStateChanged(ItemEvent ie){
  81. String tablomuz=tablo.getSelectedItem().toString();
  82. String sql="select * from "+tablomuz;
  83. sutunlar.clear();//ilk önce temizlik
  84. try{
  85. Statement stat2=pen.giris1.con.createStatement();
  86. ResultSet sutset = stat2.executeQuery(sql);
  87. ResultSetMetaData rsmd = sutset.getMetaData();
  88.  
  89. for (int i=1;i<=rsmd.getColumnCount();++i){
  90. sutunlar.add(rsmd.getColumnName(i));
  91. }
  92.  
  93. sutun.setListData(sutunlar);//sutun isimleri eklendi
  94.  
  95. stat2.close();
  96.  
  97. }catch (Exception e){System.out.println("Invalid Column");}
  98.  
  99. }
  100.  
  101. });
  102.  
  103. sutun = new JList(sutunlar);
  104. sutun.setFixedCellWidth(120);
  105. sutun.setVisibleRowCount(3);
  106. sutun.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  107. sutun.addListSelectionListener(new ListSelectionListener(){//sql ifadesi hazirlaniyor
  108. public void valueChanged(ListSelectionEvent le){
  109. Object sutunlar[]=sutun.getSelectedValues();
  110. String sutunlarim="";
  111. for(int i=0;i<sutunlar.length;i++){
  112. String sutunisim=sutunlar[i].toString();
  113. if(sutunisim.indexOf(" ")>0)
  114. sutunisim="["+sutunisim+"]";
  115. sutunlarim+=sutunisim;
  116. if(i!=sutunlar.length-1)
  117. sutunlarim+=" , ";
  118. }
  119. sorgu.setText("select "+ sutunlarim +" from "
  120. +tablo.getSelectedItem().toString());
  121.  
  122. }
  123.  
  124. });
  125. scp = new JScrollPane(sutun);
  126. sorgu = new JTextArea(3,15);
  127. sorgu.setLineWrap(true);
  128. sctext=new JScrollPane(sorgu);
  129. submit = new JButton("Submit");
  130. submit.addActionListener(new ActionListener(){//sougulama
  131. public void actionPerformed(ActionEvent ae){
  132. String sqlim=sorgu.getText();
  133. pen.sonuc.setText("");
  134. try{
  135. Statement stat3=pen.giris1.con.createStatement();
  136. ResultSet sorguset=stat3.executeQuery(sqlim);
  137. ResultSetMetaData sorgursmd=sorguset.getMetaData();
  138. int sutunsayi=sorgursmd.getColumnCount();
  139. for(int i=1;i<=sutunsayi;i++){
  140. pen.sonuc.append(sorgursmd.getColumnName(i)+"\t");
  141. }
  142. pen.sonuc.append("\n");
  143. for(int i=1;i<=sutunsayi;i++){
  144. pen.sonuc.append("-------------\t");
  145. }
  146. pen.sonuc.append("\n");
  147. while(sorguset.next()){
  148. for(int i=1;i<=sutunsayi;i++){
  149. pen.sonuc.append(sorguset.getString(i)+"\t");
  150. }
  151. pen.sonuc.append("\n");
  152.  
  153. }
  154. }catch(Exception e){System.out.println("OLMAZZZZ");}
  155. }
  156. });
  157. reset = new JButton("Reset");//temizleme
  158. reset.addActionListener(new ActionListener(){
  159. public void actionPerformed(ActionEvent ae){
  160. sorgu.setText("");
  161. pen.sonuc.setText("");
  162. }
  163.  
  164. });
  165. login = new JButton("Login");
  166. login.addActionListener(new ActionListener(){
  167. public void actionPerformed(ActionEvent ae)
  168. {
  169. pen.giris1.setVisible(true);
  170. }
  171. });
  172. add(login);add(tablo);add(scp);add(sctext);add(submit);add(reset);
  173.  
  174.  
  175.  
  176. }
  177.  
  178. public void tabloz(){//tablolar bulunuyor
  179. try{
  180. DatabaseMetaData dbmd = pen.giris1.con.getMetaData();
  181. ResultSet tabloset = dbmd.getTables(null, null, null ,null);
  182. while(tabloset.next()){
  183. String tablename = tabloset.getString("TABLE_NAME");
  184. String tabletype = tabloset.getString("TABLE_TYPE");
  185. if(tabletype.equals("TABLE"))
  186. tablo.addItem(tablename);
  187. }
  188. tabloset.close();
  189.  
  190. }
  191. catch (Exception e){System.out.println("Invalid Table");}
  192. }
  193.  
  194.  
  195. }
  196.  
  197.  
  198. class giris extends JDialog{
  199. JLabel login,password;
  200. JTextField log;
  201. JPasswordField pass;
  202. JButton enter,cancel;
  203. Container dicont;
  204. pencere pen;
  205. Connection con;
  206.  
  207. public giris(pencere vpen){
  208. this.pen = vpen;
  209. this.setSize(250,150);
  210. this.setTitle("Enter Login and Password");
  211.  
  212. login = new JLabel("Login");
  213. password = new JLabel("Password");
  214. log = new JTextField(12);
  215. pass = new JPasswordField(12);
  216.  
  217.  
  218. enter = new JButton("Enter");
  219. enter.addActionListener(new ActionListener(){
  220. public void actionPerformed(ActionEvent ae)
  221. {
  222. try{
  223. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  224. con= DriverManager.getConnection("jdbc:odbc:John",log.getText()
  225. ,pass.getText());
  226. pen.getir();
  227. }
  228. catch (Exception e){JOptionPane.showMessageDialog(pen,
  229. "Invalid Login",
  230. "Warning",
  231. JOptionPane.WARNING_MESSAGE);
  232. giris.this.setVisible(true);
  233. }
  234. }
  235. });
  236.  
  237.  
  238. cancel = new JButton("Cancel");
  239. cancel.addActionListener(new ActionListener(){
  240. public void actionPerformed(ActionEvent ae)
  241. {
  242. giris.this.setVisible(false);
  243. }
  244. });
  245. dicont= this.getContentPane();
  246. dicont.setLayout(new GridLayout(3,2));
  247. dicont.add(login);dicont.add(log);dicont.add(password);dicont.add(pass);
  248. dicont.add(enter);dicont.add(cancel);
  249. this.setLocationRelativeTo(pen);
  250.  
  251. }
  252.  
  253. }
"By the data to date, there is only one animal in the Galaxy dangerous to man—man himself. So he must supply his own indispensable competition. He has no enemy to help him."
From Time Enough for Love by Robert A. Heinlein
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 47
Reputation: Banderson is an unknown quantity at this point 
Solved Threads: 4
Banderson's Avatar
Banderson Banderson is offline Offline
Light Poster

Re: java uses or overrides a deprecated API??

 
0
  #2
Sep 12th, 2004
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.

Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 129
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

Re: java uses or overrides a deprecated API??

 
0
  #3
Sep 13th, 2004
Thank you for replying Benderson,
So it is not important great hope the teacher gives full marks.Thank you again.
"By the data to date, there is only one animal in the Galaxy dangerous to man—man himself. So he must supply his own indispensable competition. He has no enemy to help him."
From Time Enough for Love by Robert A. Heinlein
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 153
Reputation: cosi is an unknown quantity at this point 
Solved Threads: 1
cosi's Avatar
cosi cosi is offline Offline
Junior Poster

Re: java uses or overrides a deprecated API??

 
0
  #4
Sep 14th, 2004
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


Originally Posted by johnroach1985
Thank you for replying Benderson,
So it is not important great hope the teacher gives full marks.Thank you again.
In a world without walls or fences,
What use are Windows and Gates.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 129
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

Re: java uses or overrides a deprecated API??

 
0
  #5
Sep 14th, 2004
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
"By the data to date, there is only one animal in the Galaxy dangerous to man—man himself. So he must supply his own indispensable competition. He has no enemy to help him."
From Time Enough for Love by Robert A. Heinlein
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC