Jsp_Uploading_MySQL.rar

  • PUDN用户
    了解作者
  • Unix_Linux
    开发工具
  • 802KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 2
    下载次数
  • 2015-05-21 17:55
    上传日期
UPload Image , document , ppt to server using JSP
Jsp_Uploading_MySQL.rar
内容介绍
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package conPackage; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; /** * * @author Deepak */ public class MyConnection { static Connection con; public static Connection getConnection() { try { if(con==null) { Class.forName("com.mysql.jdbc.Driver"); con= DriverManager.getConnection("jdbc:mysql://localhost:3306/Jsp_Uploading_MySQL?user=root&password="); } } catch (Exception ex) { ex.printStackTrace(); } return con; } public static void CloseConnection() { if(con!=null) { try { con.close(); con = null; } catch (SQLException ex) { ex.printStackTrace(); } } } public static ResultSet getResultFromSqlQuery(String SqlQueryString) { System.out.println("in funcation"); ResultSet rs=null; if(con==null) { getConnection(); } try { rs = con.createStatement().executeQuery(SqlQueryString); } catch (SQLException ex) { ex.printStackTrace(); } return rs; } public static void main(String args[]) { getResultFromSqlQuery("select * from documents"); CloseConnection(); System.out.println("con done" + (con==null)); } }
评论
    相关推荐