These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: NHibernate.ADOException was unhandled by user code! Help!
PostPosted: Mon Oct 12, 2009 4:42 am 
Newbie

Joined: Mon Oct 12, 2009 4:35 am
Posts: 3
Location: Thailand
Hi everyone,
I'm trying to use NHibernate with Oracle 10g database, but when I try to connect it gives me an error, please help me out.

Here is my code:

hibernate.cfg.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">

  <!-- an ISessionFactory instance -->
  <session-factory>
    <!-- properties -->
    <property name="hbm2ddl.keywords">none</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
    <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.connection_string">
      User Id=tuple;
      Password=tuple007;
      Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=
      (PROTOCOL=TCP)(HOST=192.168.1.7)(PORT=1521)))
      (CONNECT_DATA=(SERVICE_NAME=ngv)));
    </property>
    <property name="connection.isolation">ReadCommitted</property>
    <property name="show_sql">false</property>
    <!-- mapping files -->
    <mapping resource="PttMapNew.Site.hbm.xml" assembly="PttMapNew" />
  </session-factory>
</hibernate-configuration>


Site.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="PttMapNew.Site, PttMapNew" table="PRIME_STATION">
    <id name="STATION_ID" column="STATIONID" type="int">
      <generator class="assigned" />
    </id>
    <property name="STATION_TYPE" column="STATIONTYPE" type="String"></property>
    <property name="STATION_NAME" column="STATIONNAME" type="String"></property>
    <property name="STATION_ADDR" column="STATIONADDR" type="String"></property>
    <property name="COMPANY_ID" column="COMPANYID" type="String"></property>
    <property name="GROUP_ID" column="GROUPID" type="int"></property>
    <property name="LAT" column="LATITIDE" type="Double"></property>
    <property name="LNG" column="LONGITUDE" type="Double"></property>
    <property name="BAY_LAT" column="BAYLAT" type="Double"></property>
    <property name="BAY_LONG" column="BAYLONG" type="Double"></property>
    <property name="TELF" column="TEL" type="int"></property>
    <property name="DISTANCE_1" column="DISTANCE1" type="int"></property>
    <property name="DISTANCE_2" column="DISTANCE2" type="int"></property>
    <property name="ZOOM_LEVEL" column="ZOOMLEVEL" type="int"></property>
  </class>
</hibernate-mapping>


Main.aspx.cs
Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NHibernate;
using NHibernate.Cfg;
using System.Data.OracleClient;

namespace PttMapNew
{
    public partial class Main : System.Web.UI.Page
    {
        Site s;
        IList siteList;
        GooglePoint marker;
        string[] sIcons = { "icons/pushpin-blue.png", "icons/rain.png", "icons/snow.png", "icons/storm.png" };
        Random Rand = new Random();
        protected void Page_Load(object sender, EventArgs e)
        {
            ISessionFactory factory = new NHibernate.Cfg.Configuration().Configure().BuildSessionFactory();
            using (ISession session = factory.OpenSession())
            {
                ICriteria sc = session.CreateCriteria(typeof(Site));
                siteList = sc.List(); // The error occurs here when i try to add the siteList from DB
                session.Close();
            }
            factory.Close();
            s = (Site)siteList[0];
            GMap.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];
            GMap.GoogleMapObject.Width = "850px";
            GMap.GoogleMapObject.Height = "500px";
            GMap.GoogleMapObject.ShowMapTypesControl = false;
            GMap.GoogleMapObject.ShowZoomControl = false;
            GMap.GoogleMapObject.ZoomLevel = 7;
            GMap.GoogleMapObject.CenterPoint = new GooglePoint("1", s.LAT, s.LNG);

            LoadMap(); // Load The Map
            LoadSideBar(); // Load The Side Bar Content
        }
        protected void LoadMap()
        {
            int i = 0;
            for (i = 0; i < siteList.Count; i++)
            {
                marker = new GooglePoint();
                s = (Site)siteList[i];
                marker.ID = s.STATION_ID.ToString();
                marker.Latitude = s.LAT;
                marker.Longitude = s.LNG;
                marker.InfoHTML = s.STATION_NAME;
                marker.ToolTip = s.STATION_ID.ToString();
                marker.IconImage = sIcons[0];
                GMap.GoogleMapObject.Points.Add(marker);
            }
        }
        protected void LoadSideBar()
        {
            if (!IsPostBack)
            {
                // Mother Tab Content Start

                DataTable MotherTable = new DataTable();
                int MotherCount = 0;
                MotherTable.Columns.Add("Station Name");
                MotherTable.Columns.Add("Station ID");
                for (MotherCount = 0; MotherCount < siteList.Count; MotherCount++)
                {
                    s = (Site)siteList[MotherCount];
                    DataRow NewMotherRow;
                    NewMotherRow = MotherTable.NewRow();
                    if (s.STATION_TYPE == "M")
                    {
                        NewMotherRow["Station Name"] = s.STATION_NAME;
                        NewMotherRow["Station ID"] = s.STATION_ID;
                        MotherTable.Rows.Add(NewMotherRow);
                    }
                }
                MotherGrid.DataSource = MotherTable;
                MotherGrid.DataBind();

                // Mother Tab Content End

                // Daughter Tab Content Start

                DataTable DaughterTable = new DataTable();
                int DaughterCount = 0;
                DaughterTable.Columns.Add("Station Name");
                DaughterTable.Columns.Add("Station ID");
                for (DaughterCount = 0; DaughterCount < siteList.Count; DaughterCount++)
                {
                    s = (Site)siteList[DaughterCount];
                    DataRow NewDaughterRow;
                    NewDaughterRow = DaughterTable.NewRow();
                    if (s.STATION_TYPE == "D")
                    {
                        NewDaughterRow["Station Name"] = s.STATION_NAME;
                        NewDaughterRow["Station ID"] = s.STATION_ID;
                        DaughterTable.Rows.Add(NewDaughterRow);
                    }
                }
                DaughterGrid.DataSource = DaughterTable;
                DaughterGrid.DataBind();

                // Daughter Tab Content End

                TrailerGrid.DataSource = siteList;
                PrimeGrid.DataSource = siteList;

                TrailerGrid.DataBind();
                PrimeGrid.DataBind();
            }
        }

        protected void MotherGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
                MotherLabel.Text = e.CommandArgument.ToString();
        }
        protected void DaughterGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
                DaughterLabel.Text = e.CommandArgument.ToString();
        }
        protected void TrailerGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
                TrailerLabel.Text = e.CommandArgument.ToString();
        }
        protected void PrimeGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
                PrimeLabel.Text = e.CommandArgument.ToString();
        }
    }
}


The error I get:

Quote:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Oracle.DataAccess.Client.OracleException:

Source Error:

Line 28: {
Line 29: ICriteria sc = session.CreateCriteria(typeof(Site));
Line 30: siteList = sc.List();
Line 31: session.Close();
Line 32: }


Source File: C:\Users\Vishan S Gill\Documents\Visual Studio 2008\Projects\PttMapNew\PttMapNew\Main.aspx.cs Line: 30

Stack Trace:

[OracleException (0x80004005)]
Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure) +278
Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src) +51
Oracle.DataAccess.Client.OracleConnection.Open() +4440
NHibernate.Connection.DriverConnectionProvider.GetConnection() +152
NHibernate.AdoNet.ConnectionManager.GetConnection() +90
NHibernate.AdoNet.AbstractBatcher.Prepare(IDbCommand cmd) +83
NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) +88
NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) +365
NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +417
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +106
NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +172

[ADOException: could not execute query
[ SELECT this_.STATIONID as STATIONID0_0_, this_.STATIONTYPE as STATIONT2_0_0_, this_.STATIONNAME as STATIONN3_0_0_, this_.STATIONADDR as STATIONA4_0_0_, this_.COMPANYID as COMPANYID0_0_, this_.GROUPID as GROUPID0_0_, this_.LATITIDE as LATITIDE0_0_, this_.LONGITUDE as LONGITUDE0_0_, this_.BAYLAT as BAYLAT0_0_, this_.BAYLONG as BAYLONG0_0_, this_.TEL as TEL0_0_, this_.DISTANCE1 as DISTANCE12_0_0_, this_.DISTANCE2 as DISTANCE13_0_0_, this_.ZOOMLEVEL as ZOOMLEVEL0_0_ FROM PRIME_STATION this_ ]
[SQL: SELECT this_.STATIONID as STATIONID0_0_, this_.STATIONTYPE as STATIONT2_0_0_, this_.STATIONNAME as STATIONN3_0_0_, this_.STATIONADDR as STATIONA4_0_0_, this_.COMPANYID as COMPANYID0_0_, this_.GROUPID as GROUPID0_0_, this_.LATITIDE as LATITIDE0_0_, this_.LONGITUDE as LONGITUDE0_0_, this_.BAYLAT as BAYLAT0_0_, this_.BAYLONG as BAYLONG0_0_, this_.TEL as TEL0_0_, this_.DISTANCE1 as DISTANCE12_0_0_, this_.DISTANCE2 as DISTANCE13_0_0_, this_.ZOOMLEVEL as ZOOMLEVEL0_0_ FROM PRIME_STATION this_]]
NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +336
NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) +46
NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) +155
NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session) +81
NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) +630
NHibernate.Impl.CriteriaImpl.List(IList results) +66
NHibernate.Impl.CriteriaImpl.List() +66
PttMapNew.Main.Page_Load(Object sender, EventArgs e) in C:\Users\Vishan S Gill\Documents\Visual Studio 2008\Projects\PttMapNew\PttMapNew\Main.aspx.cs:30
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

_________________
Vishan S Gill
Tuple Solutions Co., Ltd.
Web Solution Analyst
Email: vsgill@tuple.co.th / vishan.s.gill@gmail.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.