Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java Application Ö±½Óͨ¹ýjndiÁ¬½ÓÊý¾Ý¿â

 Ê¹ÓÃjar°ü:
 commons-pool-1.5.3.jar,tomcat-naming-common.jar,commons-pool-1.5.3-bin.zip,commons-dbcp.jar
 ×¢Òâ:jdbc Çý¶¯ÒªÓëÊý¾Ý¿â¼æÈÝ.
 package test.comm;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
public class DBConnector {
static private InitialContext ic = null;
static private DataSource ds = null;

static private void initContext(){
try {

BasicDataSource bds = new BasicDataSource();
bds.setUrl("jdbc:oracle:thin:@localhost:1521:test");
bds.setDriverClassName("oracle.jdbc.OracleDriver");
bds.setUsername("test");
bds.setPassword("a");

Hashtable<String, String> evn = new Hashtable<String,String>();
evn.put("java.naming.factory.initial","org.apache.naming.java.javaURLContextFactory");
ic = new InitialContext(evn);
ic.bind("mydatasource", bds);
ds = (DataSource) ic.lookup("mydatasource");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

static public Connection getConn() throws SQLException{
if (ds == null){
initContext();
}
return ds.getConnection();
}


}

²âÊÔ:
package test;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import test.comm.DBConnector;
public class wfTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Connection conn = DBConnector.getConn();
System.out.println("conn = "+conn);
String qSQL = "SELECT USERNAME,LOGINID from S_U_USER";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(qSQL);

while (rs.next()){
System.out.println(rs.getString("USERNAME"));
System.out.print("


Ïà¹ØÎĵµ£º

javaÈëÃÅ

 Javaѧϰ´ÓÈëÃŵ½¾«Í¨ 
Ò»¡¢ JDK (Java Development Kit) 
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......

sql 2005 ´æ´¢¹ý³Ì·ÖÒ³ java ´úÂë

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ ......

JAVA AJAX½Ì³ÌµÚËÄÕ—AJAXºÍMVCµÄ¼òµ¥½áºÏ

 ÕâÀïÎÒÃÇÔÙÀí½âÁËAJAXºó£¬¿ªÊ¼À´ÓÃʵÀý¸ÐÊÜAJAXµÄÁ¦Á¿¡£
½ñÌìÎÒ×îºóҪʵÏÖµÄЧ¹û£¬µ±Êó±ê·Åµ½Í¼Æ¬ÉÏʱ»á¸ù¾Ý£¬»á°ÑÊý¾Ý¿â¿âÀïµÄÊý¾Ý¶Á³ö£¬Í¨¹ýÏÔʾ¿òÏÔʾ³öÀ´¡£Õâ¸öÔںܶàÍøÉÏÉ̵궼ÓÐÓõ½ÕâÀïЧ¹û£¬ÎÒÃÇÕâÀïÓÃAJAXÀ´ÊµÏÖÕâ¸öЧ¹û¡£Õâ¸öʵÀýÀï½áºÏÁËMySql¡¢Servlet»¹ÓÐJs£¬ÀíÂÛÐÔºÜÉÙ£¬µ«Í¨¹ýʵ¼ùÀ´¸ÐÊÜÀíÂÛ֪ʶ¡£
......

jsp,java±àÂëÔ­Àí

Îļþ´ò¿ªÊ±ºòÊÇͨ¹ýÎļþÍ·À´È·¶¨ÎļþµÄ±àÂë
StreamReader   sr=new   StreamReader(@"F:\cym\temp\1.txt");  
  sr.CurrentEncoding   //·µ»Ø±àÂë
ÊÀ½çÉϵĸ÷µØÇø¶¼Óб¾µØµÄÓïÑÔ¡£µØÇø²îÒìÖ±½Óµ¼ÖÂÁËÓïÑÔ»·¾³µÄ²îÒì¡£ÔÚ¿ª·¢Ò»¸ö¹ú¼Ê»¯³ÌÐòµÄ¹ý³ÌÖУ¬´¦ÀíÓïÑÔÎ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ