Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Hello

...

Jogetor

...

guys,

...

I

...

wrote

...

beanshell

...

script

...

in

...

beanshell

...

tool

...

plug-in.

...

my

...

question

...

is

...

how

...

can

...

call

...

it

...

in

...

my

...

form.

Code Block
titlebeanshell
       
| import java.util.*; \\
    
	import java.sql.*; \\
    
	import javax.sql.DataSource;
	import java.io.*; \\
\\
    
	Connection conn = null; \\
       
        PreparedStatement stmt = null; \\
        try \\
        { \\
           
        try
        {
            String userName = "root"; \\
           
            String password = ""; \\
           
            String url = "jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8"; \\
           
            Class.forName ("com.mysql.jdbc.Driver").newInstance (); \\
           
            conn = DriverManager.getConnection (url, userName, password); \\
            if(\
            if(!conn.isClosed()) \\
           
{\\
                     System.out.println("exists");\\
                 }\                 else\                 {\\
                     System.out.println("not exists");\\
                 }\             " macrohasbody="false" wikihasprecedingnewline="false" wikihastrailingnewline="false" >{\\                   {
            	String sql = "SELECT Count\\(*) FROM app_fd_application WHERE app_fd_application.c_companyName = '#form.application.companyName#'";\\                 
                stmt = conn.prepareStatement(sql);\\                 
                ResultSet rs = stmt.executeQuery(sql);\\                 
                rs.next();\\                 
                boolean exists;\\                 
                if( exists = rs.getInt("COUNT\\(*)") > 0)\\                  {\\
                     
                {
                	System.out.println("exists");\\
                 }\\                  else\\                  {\\
                     
                }
                else
                {
                	System.out.println("not exists");\\
                 }\\              }             \\
        } \\
       
                }
            }
        }
        catch (Exception e) \\
        {\\
             
        {
        	System.err.println("Exception: " + e.getMessage());\\
         }\\
        finally \\
        { \\
            try
{\\
                     conn.close(); \\
                 }\             " macrohasbody="false" wikihasprecedingnewline="false" wikihastrailingnewline="false" >{ \\                  if(conn \!= null) \\                  {\\
                     conn.close(); \\
                 }\\              } \\
            catch(SQLException e) \\
            {\\
             } \\
        }  \\ |

        }
        finally
        {
            try {
                if(conn != null)
                {
                    conn.close();
                }
            }
            catch(SQLException e)
            {
            }
        }   

BR