我是 linux ubuntu 和单声道运行时的新手,我尝试像通常在 windows 中那样连接到 oracle 11G (我在 windows 中尝试了 System.Data.OracleClient 和 Oracle.OracleClient 并且都运行良好) 但我在 ubuntu 中遇到了这个问题: System.DllNotFoundException: libclntsh.so 这是堆栈跟踪:
libclntsh.so
Description: HTTP 500. Error processing request.
Stack Trace:
System.DllNotFoundException: libclntsh.so
at (wrapper managed-to-native) System.Data.OracleClient.Oci.OciCalls/OciNativeCalls:OCIEnvCreate (intptr&,System.Data.OracleClient.Oci.OciEnvironmentMode,intptr,intptr,intptr,intptr,int,intptr)
at System.Data.OracleClient.Oci.OciCalls.OCIEnvCreate (System.IntPtr& envhpp, OciEnvironmentMode mode, IntPtr ctxp, IntPtr malocfp, IntPtr ralocfp, IntPtr mfreep, Int32 xtramem_sz, IntPtr usrmempp) [0x00000] in <filename unknown>:0
at System.Data.OracleClient.Oci.OciEnvironmentHandle..ctor (OciEnvironmentMode mode) [0x00000] in <filename unknown>:0
at System.Data.OracleClient.Oci.OciGlue.CreateConnection (OracleConnectionInfo conInfo) [0x00000] in <filename unknown>:0
at System.Data.OracleClient.OracleConnectionPoolManager.CreateConnection (OracleConnectionInfo info) [0x00000] in <filename unknown>:0
at System.Data.OracleClient.OracleConnectionPool.CreateConnection () [0x00000] in <filename unknown>:0
at System.Data.OracleClient.OracleConnectionPool.GetConnection () [0x00000] in <filename unknown>:0
at System.Data.OracleClient.OracleConnection.Open () [0x00000] in <filename unknown>:0
at example.Default.button1Clicked (System.Object sender, System.EventArgs args) [0x0000d] in /home/danar/Projects/example/example/Default.aspx.cs:18
at System.Web.UI.WebControls.Button.OnClick (System.EventArgs e) [0x00000] in <filename unknown>:0
at System.Web.UI.WebControls.Button.RaisePostBackEvent (System.String eventArgument) [0x00000] in <filename unknown>:0
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (System.String eventArgument) [0x00000] in <filename unknown>:0
at System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler sourceControl, System.String eventArgument) [0x00000] in <filename unknown>:0
at System.Web.UI.Page.RaisePostBackEvents () [0x00000] in <filename unknown>:0
at System.Web.UI.Page.ProcessRaiseEvents () [0x00000] in <filename unknown>:0
at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0
at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
这是我到 oracle 的连接字符串,我使用了 System.data.oracleclient
string oradb = "Data Source=(DESCRIPTION="
+ "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))"
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));"
+ "User Id=hr;Password=hr;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
OracleCommand command=new OracleCommand();
command.Connection=conn;
command.CommandText="select * from employee";
OracleDataReader reader=command.ExecuteReader();
while(reader.Read())
{
Response.Write(reader[0]+"<br>");
}
conn.Close();
command=null;
reader.Close();
reader=null;