你在WEBLOGIC中配置数据源了吗?

解决方案 »

  1.   

    看看,环境里有没有ORACLE的JAR
      

  2.   

    我配了.
    环境里有
    其中:startWebLogic.cmd
    @ECHO OFF@REM WARNING: This file is created by the Configuration Wizard.
    @REM Any changes to this script may be lost when adding extensions to this configuration.SETLOCAL@REM *************************************************************************
    @REM This script is used to start WebLogic Server for the domain in the
    @REM current working directory.  This script simply sets the SERVER_NAME
    @REM variable and starts server.
    @REM 
    @REM To create your own start script for your domain, all you need to set is
    @REM SERVER_NAME, then starts the server.
    @REM 
    @REM Other variables that startWLS takes are:
    @REM 
    @REM WLS_USER     - cleartext user for server startup
    @REM WLS_PW       - cleartext password for server startup
    @REM PRODUCTION_MODE    - true for production mode servers, false for
    @REM                development mode
    @REM JAVA_OPTIONS - Java command-line options for running the server. (These
    @REM                will be tagged on to the end of the JAVA_VM and MEM_ARGS)
    @REM JAVA_VM      - The java arg specifying the VM to run.  (i.e. -server,
    @REM                -hotspot, etc.)
    @REM MEM_ARGS     - The variable to override the standard memory arguments
    @REM                passed to java
    @REM 
    @REM For additional information, refer to the WebLogic Server Administration
    @REM Console Online Help(http:\\e-docs.bea.com\wls\docs81\ConsoleHelp\startstop.html)
    @REM *************************************************************************@REM Initialize the common environment.set WL_HOME=D:\bea\weblogic81
    for %%i in ("%WL_HOME%") do set WL_HOME=%%~fsiset PRODUCTION_MODE=set JAVA_VENDOR=BEAset JAVA_HOME=D:\bea\jrockit81sp3_142_04
    for %%i in ("%JAVA_HOME%") do set JAVA_HOME=%%~fsi@REM Call commEnv here AFTER setting the java_vendor to get common environmental settings.call "%WL_HOME%\common\bin\commEnv.cmd"@REM Set SERVER_NAME to the name of the server you wish to start up.set SERVER_NAME=myserverset CLASSPATH=%WEBLOGIC_CLASSPATH%;%POINTBASE_CLASSPATH%;%JAVA_HOME%\jre\lib\rt.jar;%WL_HOME%\server\lib\webservices.jar;D:\oracle\ora92\jdbc\lib\classes12_g.zip;D:\bea\user_projects\domains\mydomain\myserver\office\OfficeLog\WEB-INF\classes;%CLASSPATH%@REM Call WebLogic Serverecho .
    echo CLASSPATH=%CLASSPATH%
    echo .
    echo PATH=%PATH%
    echo .
    echo ***************************************************
    echo *  To start WebLogic Server, use a username and   *
    echo *  password assigned to an admin-level user.  For *
    echo *  server administration, use the WebLogic Server *
    echo *  console at http:\\[hostname]:[port]\console    *
    echo ***************************************************%JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% -Dweblogic.Name=%SERVER_NAME% -Dweblogic.ProductionModeEnabled=%PRODUCTION_MODE% -Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" weblogic.ServerENDLOCAL
      

  3.   

    config.xml:<?xml version="1.0" encoding="UTF-8"?>
    <Domain ConfigurationVersion="8.1.3.0" Name="mydomain">
        <Server ListenAddress="" ListenPort="7001" Name="myserver"
            NativeIOEnabled="true" ReliableDeliveryPolicy="RMDefaultPolicy" ServerVersion="8.1.3.0">
            <SSL Enabled="false" HostnameVerificationIgnored="false"
                IdentityAndTrustLocations="KeyStores" Name="myserver"/>
        </Server>
        <JMSFileStore Directory="rmfilestore" Name="FileStore"/>
        <WSReliableDeliveryPolicy DefaultRetryCount="10"
            DefaultTimeToLive="60000" Name="RMDefaultPolicy" Store="FileStore"/>
        <Security Name="mydomain"
            PasswordPolicy="wl_default_password_policy"
            Realm="wl_default_realm" RealmSetup="true"/>
        <EmbeddedLDAP
            Credential="{3DES}lymFRsl+th5OGdtx3jrXo3gNeBnaMz2wnsur28B224E=" Name="mydomain"/>
        <SecurityConfiguration
            Credential="{3DES}Bbzg3qDCLsNrANaKbWCwKtR5wDtacJ8p7VHffBSZZbSfo+h3w4agSawq3+N9vajTltuv7vEyytayl4mobnfz6Uqg5yELZX3f"
            Name="mydomain" RealmBootStrapVersion="1"/>
        <Realm FileRealm="wl_default_file_realm" Name="wl_default_realm"/>
        <FileRealm Name="wl_default_file_realm"/>
        <PasswordPolicy Name="wl_default_password_policy"/>
        <JMSServer Name="WSStoreForwardInternalJMSServermyserver"
            Store="FileStore" Targets="myserver">
            <JMSQueue CreationTime="1119923192406"
                JNDIName="jms.internal.queue.WSStoreForwardQueue"
                JNDINameReplicated="false" Name="WSInternaljms.internal.queue.WSStoreForwardQueuemyserver"/>
            <JMSQueue CreationTime="1119923192953"
                JNDIName="jms.internal.queue.WSDupsEliminationHistoryQueue"
                JNDINameReplicated="false" Name="WSInternaljms.internal.queue.WSDupsEliminationHistoryQueuemyserver"/>
        </JMSServer>
        <Application Deployed="true" Name="OfficeLog"
            Path="D:\bea\user_projects\domains\mydomain\myserver\office" TwoPhase="true">
            <WebAppComponent Name="OfficeLog" Targets="myserver" URI="OfficeLog"/>
        </Application>
        <JDBCConnectionPool DriverName="oracle.jdbc.OracleDriver"
            Name="MyJDBC Connection Pool" Password="{3DES}smcx+ytKo48="
            Properties="user=hifs3i" Targets="myserver"
            TestConnectionsOnCreate="true" TestConnectionsOnRelease="true"
            TestTableName="SQL SELECT * FROM CZYK" URL="jdbc:oracle:thin:@localhost:1521:YO9I"/>
        <JDBCTxDataSource JNDIName="hifs3i" Name="MyJDBC Data Source"
            PoolName="MyJDBC Connection Pool" Targets="myserver"/>
        <JDBCConnectionPool DriverName="weblogic.jdbc.oci.Driver"
            Name="MyJDBC Connection Pool-1" Password="{3DES}smcx+ytKo48="
            Properties="user=hifs3i;server=YO9I" Targets="myserver"
            TestConnectionsOnCreate="true" TestConnectionsOnRelease="true"
            TestTableName="SQL SELECT * FROM CZYK" URL="jdbc:weblogic:oracle"/>
        <JDBCTxDataSource JNDIName="hifs3i" Name="MyDataSource"
            PoolName="MyJDBC Connection Pool-1" Targets="myserver"/>
    </Domain>
      

  4.   

    package com.Mof;
    import java.sql.*;
    import java.io.*;public class DbADO {
       Connection  conn=null;
       Statement  stmt=null;
       ResultSet  rs=null;
       public DbADO() {  }
    //使用JDBC连接数据库
     public boolean connect()
     {
           
           boolean isConnect=false;
      try 
      {
              
       Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();// oracle.jdbc.OracleDriver
       //Class.forName("oracle.jdbc.OracleDriver").newInstance();
               String  url=" jdbc:oracle:thin:@localhost:1521:OY9I";  //jdbc:oracle:thin:@localhost:1521:YO9I
                //OY9I数据库名SID  
               String  dbuser="hifs3i";  
               String  dbpassword="hifs3i"; 
                
               conn=  DriverManager.getConnection(url,dbuser,dbpassword);  
               
               if (conn!=null)
                     isConnect=true;
               
       }
       catch(Exception e)
       {
                 System.out.println("connect to database failed");
                 e.printStackTrace();
       }
       
       return isConnect; }
          
      //查询操作
       public ResultSet select(String sql)
      {
              try{
              
               stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                rs=stmt.executeQuery(sql);           
                           
               }
              catch(Exception e)
              {
                e.printStackTrace();
              }
              return rs;
      }
      //插入,修改,删除操作
       public int update_insert(String sql)
      {
            int num=0;
            try{
              stmt = conn.createStatement(); 
              stmt.executeUpdate(sql);
                          
            }
            catch(Exception e)
            {
              e.printStackTrace();
            }
            return num;  }
      //查询记录总条数
      public int total(String sql)
      {
              int num=0;
              
              try{
               stmt = conn.createStatement();   
               rs=stmt.executeQuery(sql);  
                
                while(rs.next())
                {
                  num=rs.getInt(1);
                 }
                
               }
              catch(Exception e)
              {
                e.printStackTrace();
              }
              return num;
      }
      //关闭数据库连接,释放资源
      public void close()
      {
          try{
             if(rs!=null)
                 rs.close();
                 
              rs=null;
              
              if(stmt!=null)
                 stmt.close();
              
              stmt=null;
              
              if(conn!=null)
                  conn.close();
              
          }
          catch(Exception e)
          {
             e.printStackTrace();
          }
          finally
          {
                
                 conn = null;
          }
          
       }
      
      }