Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


Call bean, consult experts

Below are two bean bag in the data, a database linked to the implementation of the translation would not be a problem,
The second is to use a bean for the completion of the actual database connection data exchange methods, but always mistakes in the translation error to help look for the following : Which error debugging help, be grateful! ! !
[color=red]viewdata.java:18 Can not resolve symbol :
Symbol : 14.00 Dbcon
Location data package :
Data.Dbcon dc=null;
      ^
Viewdata.java:22 can not resolve symbol :
Symbol : 14.00 Dbcon
Location : 14.00 data.ViewData
Dc=new Dbcon ();
           ^
2 errors [/color]_____________________________________________----
[color=green][color=red]Dbcon.java
________________________________________________---- [/color][/color]
Package data;
Import java.lang.*;
Import java.util.*;
Import java.sql.*;
Import java.io.*;


/**gffsgfsfgffgs
* "P>;Title :" /p>;
* "P>;Description :" /p>;
* "P>;Copyright : Copyright (c) 2003</p>;
* "P>;Company :" /p>;
*author Not attributable
*version 1.0
*/

Public class Dbcon{
Public Connection conn = null;
Public Statement stmt = null;
Public ResultSet rset = null;
Public Dbcon () (

  }

Public boolean openCon () (
String jdbc = "com.mysql.jdbc.Driver";
String government payments are capped = "jdbc:mysql://localhost:3306/counter";
String user= "aaaaa";
String password = "aaaaa";

//--step 3
//-- Strategy
//--step Driven four loading jdbcjdbc
//-- Strategy
Try (
Class.forName (jdbc);

    }
Catch (ClassNotFoundException e) (
System.out.println ( "jdbc invasion mistakes" + e.getMessage ());
Return false;
    }
//step5. Open database con
Try (
This.conn = DriverManager.getConnection (government payments are capped, user, password);
    }
Catch (SQLException e) (
System.out.println ( "Generation connection error :" + e.getMessage ());
Return false;

    }
Return true;

  }

  /***********
* ExecuteQuery method name :
* Query parameters : (sgl words)
* Java.sql.ResultSet return value type :
   * **********
   */
Public ResultSet executeQuery (String query) throws SQLException --
This.stmt = conn.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
This.rset = stmt.executeQuery (query);
Return rset;
  }

  /*********
* Name : executeUpdate method
* Parameters : qufery (sgl words)
* Void return type :
* Note : The revised method of data
* (UPDATE, Base DELETE, and INSERT)
   */
Public void executeUpdate (String query) throws SQLException
  {
This.stmt = conn.createStatement (java.sql.ResultSet.TYPE_SCROLL_SENSITIVE, java.sql.ResultSet.CONCUR_UPDATABLE);
Stmt.executeUpdate (query);
If (stmt!=null) stmt.close ();
        }
        /********
* Name : close approach
* Parameters : None
* Void return value :
         */
Public void close () throws SQLException
     {
If (conn!=null) conn.close ();
If (rset!=null) rset.close ();
If (stmt!=null) stmt.close ();
     }
     /******
* Name : finalize method
* Parameters : None
* Void return value type :
            */
Protected void finalize () throws Throwable{
This.close ();
              }



}


_____________________________
[color=red]Viewdata.java
________________________------ [/color]
Package data;
Import java.lang.*;
Import java.util.*;
Import java.sql.*;
Import java.io.*;


/**
* "P>;Title :" /p>;
* "P>;Description :" /p>;
* "P>;Copyright : Copyright (c) 2003</p>;
* "P>;Company :" /p>;
*author Not attributable
*version 1.0
*/

Public class ViewData{
Data.Dbcon dc=null;
ResultSet rset=null;
Public ViewData ()
  {
Dc=new data.Dbcon ();
  }
//*** Generation connection
  //****
Public boolean openCon ()
   {
Return dc.openCon ();
        }
//*** Implementation sgl (insert) /
Public void executeQuery (String query) throws SQLException
    {
This.rset =dc.executeQuery (query);
    }
//*** Implementation sgl (update, delete. . . . ) /
Public void excuteUpdate (String query) throws SQLException
      {
Dc.executeUpdate (query);
      }
//*** Get all column./
Public int getColumnCount () throws SQLException
      {
ResultSetMetaData rsmd =rset.getMetaData ();
Return rsmd.getColumnCount ();
      }

Column numbers obtained by searching the name //*** /
Public String getColumnName (int index) throws SQLException
      {
ResultSetMetaData rsmd =rset.getMetaData ();
Return rsmd.getColumnName (ENH);
      }
//*** Through the column index data acquisition /
Public String getData (int index) throws SQLException
       {
Return rset.getString (ENH). Trim ();
       }
//*** Column by the name of data acquisition /
       //*****************************
Public String getData (String columnName) throws SQLException
        {
Return rset.getString (columnName). Trim ();

        }

//*** Will scale down resultset record
/*******************/
Public boolean next () throws SQLException
        {
Return rset.next ();
        }

//***close
         /********
          *
          */
Public void close () throws SQLException
         {
If (rset!=null) rset.close ();
If (dc!=null) dc.close ();
         }
//*******finalize ()
         // ?*********/
Protected void finalize () throws Throwable
        {
Close ();

        }


}

Call bean, consult experts

Changed
Dbcon dc=null; try, try to name a packet



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com