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

Á¬½Óoracle£¬sqlserverÖÐÊý¾Ý¿âµÄʾÀý´úÂë

Ò» ÔÚOracleÖÐÁ¬½ÓÊý¾Ý¿â
public class Test1 {
 public static void main(String[] args) {
  try {
   Class.forName("oracle.jdbc.driver.OracleDriver");
   Connection conn = DriverManager.getConnection(
                           Ö÷»úÃû ¶Ë¿Ú SID      ÕʺŠ   ÃÜÂë
     "jdbc:oracle:thin:@haha:1521:oracle", "hehe", "a");
   Statement stt = conn.createStatement();
   ResultSet rs = stt.executeQuery("select * from emp");
   while (rs.next()) {
    System.out.print(rs.getObject(2).toString());
    System.out.println("\t" + rs.getObject(3).toString());
   }
   rs.close();
   stt.close();
   conn.close();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }
}
¶þ ÔÚsqlserverÖÐÁ¬½ÓÊý¾Ý¿â
public class DBManager {
 String url="jjdbc:microsoft:sqlserver://localhost:1433;databaseName='student'";
 String driver ="com.microsoft.jdbc.sqlserver.SQLServerDriver";
 String useName="sa";
 String pwd="sa";
 Connection con =null;
 Statement sta=null;
 ResultSet rs=null;
 
 public ResultSet getQiery(String sql)
 {
  try {
   Class.forName(driver);
   con =DriverManager.getConnection(url,useName,pwd);
   sta = con.createStatement();
   rs =sta.executeQuery(sql);
  } catch (Exception e) {
        e.printStackTrace();
  }
  return rs;
 }
 public int getUpd(String sql)
 {
  int i=0;
  try {
&nb


Ïà¹ØÎĵµ£º

SQLServerºÍOracle³£Óú¯Êý¶Ô±È


Êýѧº¯Êý
ÔÚoracle ÖÐdistinct¹Ø¼ü×Ö¿ÉÒÔÏÔʾÏàͬ¼Ç¼ֻÏÔʾһÌõ
¡¡¡¡1.¾ø¶ÔÖµ
¡¡¡¡S:select abs(-1) value
¡¡¡¡O:select abs(-1) value from dual
¡¡¡¡2.È¡Õû(´ó)
¡¡¡¡S:select ceiling(-1.001) value
¡¡¡¡O:select ceil(-1.001) value from dual
¡¡¡¡3.È¡Õû£¨Ð¡£©
¡¡¡¡S:select floor(-1.001) value ......

oracleÓësqlserverÖ´ÐÐcount(*)·µ»ØµÄ½á¹û¼æÈÝ

ÓÉÓÚÒÔÇ°¶¼ÊÇÔÚsqlserver 2005´¦Àí£¬ÏÖÔÚ¿Í»§ÒªÇóoracleÊý¾Ý¿â·þÎñÆ÷£¬
×î³õµÄ´úÂëΪ£º
allRecordSize = (Integer) rs1.getObject(1);    //Integer allRecordSize=0;
µ±Ö´ÐеÄʱºò±¨£ºBigDecimalÎÞ·¨×ª»¯ÎªIntegerÀàÐÍ
ΪÁ˼æÈÝÁ½ÕßÐ޸ĺóµÄ´úÂëΪ£º
  Object o = rs1.getObject(1);
 &nbs ......

SqlServer´æ´¢¹ý³Ì·ÖÒ³

--TOP n ʵÏÖµÄͨÓ÷ÖÒ³´æ´¢¹ý³Ì(ת×Ô×Þ½¨)
CREATE PROC sp_PageView
@tbname sysname, --Òª·ÖÒ³ÏÔʾµÄ±íÃû
@FieldKey nvarchar(1000), --ÓÃÓÚ¶¨Î»¼Ç¼µÄÖ÷¼ü(Ωһ¼ü)×Ö¶Î,¿ÉÒÔÊǶººÅ·Ö¸ôµÄ¶à¸ö×Ö¶Î
@PageCurrent int=1, --ÒªÏÔʾµÄÒ³Âë
@PageSize int=10, - ......

Sqlserver ´æ´¢¹ý³Ì´ó¼¯ºÏ

 =================·ÖÒ³==========================
/*·ÖÒ³²éÕÒÊý¾Ý*/
CREATE PROCEDURE [dbo].[GetRecordSet] 
@strSql varchar(8000),--²éѯsql,Èçselect  * from [user]
@PageIndex int,--²éѯµ±Ò³ºÅ
@PageSize int--ÿҳÏÔʾ¼Ç¼
AS
set nocount on
declare @p1 int
declare @current ......

sqlserver µÄprepare·½·¨Ê¹ÓÃÎÊÌâ

1.Èç¹ûÏÈprepare ºóÌí¼Ó²ÎÊý£¬ÕâÑùÒ»²¿·ÖÊý¾ÝÀàÐÍ¿ÉÒÔ²»ÓÃÉèÖÃÆäsize´óС£¬ÀýÈçchar
2.Èç¹ûÏÈÌí¼Ó²ÎÊýÔÙprepare£¬¾Í±ØÐëÉèÖòÎÊýµÄÀàÐÍ£¬´óС£¬¾«¶È²ÅÄÜͨ¹ý£¬±ÈÈçchar,varchar,decimalÀàÐÍ£¬¶øint,floatÓй̶¨×Ö½ÚÀàÐ͵ÄÊý¾ÝÀàÐÍÔò¿É²»ÓÃÉèÖôóС¡£
3.¹ØÓÚSqlServerµÄtimestampÀàÐÍ£º¸ÃÀàÐÍΪSqlServerµÄʱ¼ä´ÁÀàÐÍ£¬´´½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ