SQL dev to connect via odbc to non-oracle db
Question asked to me regarding the use of sql dev to connect to a Turbo Image databsae running on a HP-3000 through odbc. They have odbc drivers, but the front-end client is no longer supported and are looking for an alternative. I've never used Dev of SQL to connect to a non-oracle database, but it seems as it should, maybe with the OTG for odbc.
Ideas?
We are a java application. Yes JDBC.
And we offer only 3rd connectivity to help migration of Oracle. Currently we do not support Turbo-Image of database migration to Oracle.
There are however several ODBC database generic tools out there.
Tags: Database
Similar Questions
-
ADDM report is not produced by SQL DEV if connected 4.0 user is not SYSDBA privilege
Hello-
SQLDEV 4.0 (early adapter), I logged in as a user with SYSDBA privileges. But ADVICE given and run DBMS_ADDM granted and "select any dictionary" granted, etc..
Then I go in the menu view-> DBA--> Performance-> automatic database diagnostic monitor
Select report ADDM in the choices available.
Off the menu 3 options: summary, results and report ADDM, I can see the first two, but I get a grey screen for report ADDM.
^^^^^^^^^^^^^^^^^^^^^
If I do exactly the same thing but connection as SYSDBA, ADDM report can be produced and can be seen. So, the question is the lack of subsidies and privileges.
^^^^^^^^^^^^^^^^^^^^^^
The goal we are pursuing in our shop is to give developers to work with reports of the ADDM by connect non-SYSDBA user.
^^^^^^^^^^^^^^^^^^^^^^^^
Please tell us what privilege must be granted to get this working for a non-SYSDBA connection
The same user can successfully run $ORACLE_HOME/rdbms/admin/addmrpt.sql and produce files with ADDM full report. But not able to get the ADDM of SQL DEV 4.0
Thank you
VR
Hi RV,.
The security model for the DBMS_ADVISOR package means that a database user can only generate reports for ADDM tasks created by this user. To create a task SQLDev ADDM, invoke the action "Performance / automatic database Diagnostic monitor-> run ADDM. Once this is done, you should be able to generate and view report 'ADDM' for the new task.
In order to accomplish the above, you should probably add the following privileges to your user name: -.
Executer run on dbms_workload_repository, Advisor, select any dictionary and select_catalog_role
I hope this helps.
Best regards
Phil Richens.
SQLDev development team.
-
Copy of database SQL Developer - you can copy a database non-Oracle?
I was hoping to use the database copy utility in Oracle SQL Developer 4.0.2.15 to copy data from a sybase database table in an oracle database table. I created both the Sybase and Oracle database connections, however only the Oracle connection is available in the 'Source' and 'Destination connection' lists drop-down in the copy database wizard. Is it possible to use this utility to copy a non-Oracle database, any advice would be much appreciated.Assuming that you don't have just to copy a single table (or just a handful of tables), 'copy Oracle"function should appear when you right click on your target table from the Tables node on the sybase connection.
If you need to migrate tables more this can become tedious, but in this case probably consider using specially designed SQLDeveloper migration functions to migrate all drawings of third to Oracle databases (for this right click on the connection to sybase and choose "Migrate to Oracle").
-
Non-Oracle DB with SQL Developer
I wonder if any body knows if the SQL Developer "Requester" can work with databases non-Oracle? (using connection drivers we can connect to a database)
I have to work with Teradata now, but the Oracle tool was perfect for me, now I want to use this tool to make complex queries.
Any advise?
I remember well, version 3.0, SQL Developer under license from a third-party tool (see ActiveQueryBuilder.jar) to replace the old Query Builder. This tool offers support for several flavors of SQL on several RDBMS platforms. The problem was, our team began to hear about problems with the query designer on the Oracle RDBMS as well as issues with more complex Oracle SQL queries which does not correctly handle the third-party tool.
For various reasons, including limited control on bug fixing by the third party and emphasizing the support of third-party RDBMS Oracle migration, it was decided to take the position Query Builder provided as a tool for Oracle SQL non-expert programmers.
I do not exactly remember when support for Oracle NON-SQL got off, but you can start with the 3.2.2 version to see if that allows him to always...
SQL Developer downloads version 3.2.2
.. .and chain backwards (see the link at the bottom of the page) to a previous version if necessary.
Hope this helps,
Gary
SQL development team
-
Get ORA-28562 with link of database when select NULL via ODBC
Hello
This is my first post of the time issue in this community. Apologies if this isn't the right place to start and lease let me know where to post this instead.
I have a database link to connect via odbc to Ingres. Everything works as expected but when I try to select ODBC (HS), where the column is NULL, it returns the error:
Select * from mynull@ingres;
ORA-28562: heterogeneous Services data truncation error
ORA-02063: preceding line of INGRES
This is the track that counts:
hgoftch2, line 139: print hoada @ 0xe55288
MAX: 1, SIZE: 1, BRC:1, WHT = 5 (SELECT_LIST)
hoadaMOD bit-values found (0x200: TREAT_AS_CHAR)
DTY NULL-OK LEN MAXBUFLEN PR/SC CSE IND MOD NAME
VARCHAR Y 1 1 12 0 / 0 0 0 200 col1
SQLFetch: rank: 1, column 1, bflsz: 2, bflar:-1
SQLFetch: rank: 1, column 1, bflsz: 2, bflar: SQL_NULL_DATA
1 lines read
Here's the hsinit:
#
# HS init parameters
#
HS_FDS_CONNECT_INFO = rd-cdsuat02
HS_FDS_TRACE_LEVEL = DEBUG
HS_FDS_TRACE_LEVEL0 = 255
#HS_FDS_FETCH_ROWS = 1
HS_FDS_SHAREABLE_NAME = /opt/Ingres/IngresII/ingres/lib/libiiodbcdriver.1.so
HS_LANGUAGE = AMERICAN_AMERICA.we8iso8859P1
#HS_KEEP_REMOTE_COLUMN_SIZE = REMOTE
#
# ODBC specific environment variables
#
Set ODBCINI=/opt/Ingres/IngresII/ingres/files/odbc.ini
The values in the table mynull on the side of Ingres is added as follows:
create table mynull (col1 char (1) with the null value);
insert into mynull values (NULL);
The idea is to use the database link to convert the Ingres on Oracle data. I have the tables all created and copied 90% of the data, but stuck with all the data that has NULL values in it. Can someone tell me what I did not right?
Thank you
HY
Hi Mike,.
Thanks for spending the time to answer my question. Just to let you know that I discovered that I need to add this in my hs init file:
HS_FDS_SQLLEN_INTERPRETATION = 32
This solved the problem I have. Now, I get NULL value correctly. Before closing the issue, here is the info you requested. Thanks again for the help.
1. you use DG4ODBC to connect to Ingres? If so, what is the version?
Yes, not sure about the version that is part of the Oracle 12 C.
2. What is the name and the version of the ODBC of Ingres driver that you use?The driver name is Ingres and version: 3.50.1010.0137
3. What is returned by - describe "mynull"@gtw_link ".
-do not put a semicolon at the end of the describe.
02:04:21 wswmvzwd [SYS] > describe mynull@ingres
Name Null? Type
----------------------------------------------------------------------------------------------------------- -------- ------------------------------------------------------------------------
col1 VARCHAR2(1)
4. what happens if you use NVL in the selection from Oracle?
Previously, it is fixed:
12:15:39 wswmvzwd [SYS] > select * from mynull@ingres;
ERROR:
ORA-28562: heterogeneous Services data truncation error
ORA-02063: preceding line of INGRES
no selected line
Elapsed time: 00:00:00.13
After it is fixed (added HS_FDS_SQLLEN_INTERPRETATION = 32):
12:17:03 wswmvzwd [SYS] > select nvl ("col1", 'NULL') of mynull@ingres;
NVL)
----
NULL VALUE
A
NULL VALUE
5. you have-
HS_FDS_SHAREABLE_NAME = /opt/Ingres/IngresII/ingres/lib/libiiodbcdriver.1.so-is the Ingres driver or a driver manager libiiodbcdriver.1.so?
Ingres driver
-If the pilot can you confirm it offers the features of driver as Manager?Yes, I was able to check it out since the Manager ODBC INgres for the test.
6. can you upload a track of comprehensive gateway somewhere so that see us? Use-
HS_FDS_TRACE_LEVEL = 255
for the trace.
Since it is resolved, I'll ignore it. Part of the debugging information is in the original post.
Thanks again Mike, really appreciated.
HY
-
Hello
I've given cluster and can store files and it is clustering ID in the new database using the ODM. I group these data via SQL dev. Oracle again but I'm not for any folder for the storage of cluster ID. How do I? can I put something in response or detail node?Hi Nasiri,
In your description, you have only the Cluster node as entry in the node to apply it. You should also connect a node type of source of data as well. Just to get this to work, why not connect the source of input data to your Cluster node to the node to apply it. If the node to apply it should have 2 inputs, a node of type of data source, but also a model node.
Thank you, Mark -
Windows XP cannot create connection DSN ODBC in SQL Server to SQL Server
I create an ODBC SQL Server DSN connection on my desktop Windows XP domain. I select the system DSN and ADD. I select SQL Server, and it will return to the original system DSN screen. What's wrong? Has anyone seen this problem? There is another on the list system DSN data source so I know that the possibility existed before.
Hi Pearlyshells,
I would have you post your query in the MSDN Forums, because it is addressed to an audience of it professionals.
Your request would be more out there.
Check out the link-
http://social.msdn.Microsoft.com/forums/en/category/SQLServer
Thank you.
-
Database Move Virtual Center connected with ODBC to SQL 2005 server to another SQL server 2005
Is there any official document of VMware to move VC a server to other sql DB? I would like to move VC DB (connected by ODBC) to another SQl server 2005.
This article can be useful
-
Hi, I am creating the database link from a database of Oracle 11 g PostgreSQL with DG4ODBC and unixODBC
My configured for /etc/odbc.ini
[PostgreSQL]
Description = Test to Postgres
Driver = psqlodbc
Trace = Yes
Trace file = /tmp/sql.log
Database = danieldb
ServerName =
UserName = SA
Password = password
Port = 5432
Protocol = 6.4
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
My configured for /etc/odbcinst.ini
[ODBC]
CommLog = 1
Debug = 1
FileUsage = 1
Layout common = No
Trace = 1
[psqlodbc]
Description = PostgreSQL ODBC driver
Driver=/usr/lib64/psqlodbcw.so
CommLog = 1
Debug = 0
FileUsage = 1
My configured for /u01/app/oracle/product/11.2.0/xe/hs/admin/initPostgreSQL.ora
HS_FDS_CONNECT_INFO = PostgreSQL
HS_FDS_TRACE_LEVEL = 0
HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbcpsql.so
Set ODBCINI=/etc/odbc.ini
My configured for /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener =
(ADDRESS = (PROTOCOL = TCP) (HOST = oracle-poc)(PORT = 1521))
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PostgreSQL)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe)
(PROGRAM = dg4odbc)
(ENVS="LD_LIBRARY_PATH=/usr/lib64:/u01/app/oracle/product/11.2.0/xe/lib')
)
)
My configured for /u01/app/oracle/product/11.2.0/xe/network/admin/tnsname.ora
PostgreSQL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = oracle-poc)(PORT = 1521))
(CONNECT_DATA =
(SID = PostgreSQL)
)
(HS = OK)
)
I'm trying to created public database link:
CREATE DATABASE LINK PUBLIC 'orapos' CONNECT to 'HIS' IDENTIFIED BY 'password' USING 'PostgreSQL ';
When I used tnsping
[root@oracle-poc admin] # tnsping PostgreSQL
AMT Ping utility for Linux: Version 11.2.0.2.0 - Production on May 16, 2013 20:34:19
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Use settings files:
/U01/app/Oracle/product/11.2.0/XE/network/admin/SQLNET.ora
TNSNAMES adapter used to resolve the alias
Try to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = oracle-poc)(PORT = 1521)) (CONNECT_DATA = (SID = PostgreSQL)) (HS = OK))
OK (0 msec)
and finally, I try to use the database link:
"SQL > select * from tabel2"@orapos ".
2;
Select * from 'tabel2"@orapos '.
*
ERROR on line 1:
ORA-28500: connection between ORACLE and a non-Oracle system has sent this message:
ORA-02063: preceding the line of ORAPOS
What wrong with my setup?
Thank you and best regards,
Daniel
Daniel,
The problem is that you are using the ODBC Postgres driver for the HS_FDS_SHAREABLE_NAME parameter, but this must be an ODBC driver manager and not the driver ODBC Psotgres.
Go to the.Click the 'Download' and follow the instructions to download the 2.3.1 pilot and make libraries and programs.
Once this is done, then use the driver as parameter HS_FDS_SHAREABLE_NAME Manager, for example-
HS_FDS_SHAREABLE_NAME =/home/odbc64/unixODBC/2.3.1/lib/libodbc.so
Depending on where you install it.
Kind regards
Mike
-
How to authenticate a direct connection via JDBC?
Hello world
I have the following problem. There are the following DSN configured in my sys.odbc.ini:
NMDS_E = driver Client TimesTen 11.2.1
NMDS_D = Driver 11.2.1 TimesTen
...
[NMDS_E]
Driver=/opt/TimesTen/tt1121/lib/libtten.so
Data store = / var/tmp/NM/NMDS_E
LogDir = / var/tmp/NM
DatabaseCharacterSet = AL32UTF8
PermSize = 200
[NMDS_D]
Driver=/opt/TimesTen/tt1121/lib/libtten.so
Data store = / var/tmp/NM/NMDS_E
LogDir = / var/tmp/NM
DatabaseCharacterSet = AL32UTF8
PermSize = 200
UID = anmdb_user
PWD = anmdb_user
If I try to connect via ttIsql, it works:
Connect "DSN is NMDS_D ';.
Successful login: DSN = NMDS_D; UID = anmdb_user; DataStore = / var/tmp/NM/NMDS_E; DatabaseCharacterSet = AL32UTF8; ConnectionCharacterSet=US7ASCII;DRIVER=/opt/TimesTen/tt1121/lib/libtten.so; LogDir = / var/tmp/NM; PermSize = 200; TypeMode = 0;
But if I try to connect to the JDBC driver NMDS_D via, it fails:
java.sql.SQLException: [TimesTen] [driver ODBC of TimesTen 11.2.1.8.4] TT7001 [TimesTen]: user authentication failed - file "db.c", lineno 9718, procedure 'sbDbConnect '.
at com.timesten.jdbc.JdbcOdbc.createSQLException(JdbcOdbc.java:3232)
at com.timesten.jdbc.JdbcOdbc.standardError(JdbcOdbc.java:3381)
at com.timesten.jdbc.JdbcOdbc.standardError(JdbcOdbc.java:3346)
at com.timesten.jdbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:796)
at com.timesten.jdbc.JdbcOdbcConnection.connect(JdbcOdbcConnection.java:1814)
at com.timesten.jdbc.TimesTenDataSource.getConnection(TimesTenDataSource.java:148)
...
The following URL is used for the connection:
JDBC:TimesTen:direct:driver=/opt/TimesTen/tt1121/lib/libtten.so;DSN=NMDS_D;datastore=/var/tmp/nm/NMDS_E; ConnectionCharacterSet = AL32UTF8;
Could someone help me with this?
Best regards
Dmitriy.
Hi Dimitri.
Point 1. NMDS_E is not a 'customer' DSN it equates to a direct DSN NMDS_D mode and so the line at the beginning of the gall sys.odbc.ini must really say:
NMDS_E = Driver 11.2.1 TimesTen
This question is not relevant to your current issue but could cause you problems in the future if you do not correct it.
The problem here is that you provide too much information in the JDBC URL. You're basiccally bypassign what is configured in the sys.odbc.ini file. A 'normal' JDBC URL connection looks like this:
JDBC:TimesTen:direct:NMDS_D
If you try it then it must pick up the UID and PWD from the file. Of course, this is terribly insecure and you should never hard UID or PWD in a code file. You really should provide as part of the JDBC connection call.
Chris
-
I have unixodbc and freetds. Since isql I can connect to ms sql server. Oracle sqlplus, I get:
SQL > SELECT * FROM 'Banks"@EIMS;
SELECT * FROM 'Banks"@EIMS '.
*
ERROR on line 1:
ORA-28500: connection between ORACLE and a non-Oracle system has sent this message:
[unixODBC] [FreeTDS] [SQL Server] Unable to connect to data
source [unixODBC] [SQL Server] Adaptive Server [FreeTDS] login
has failed [unixODBC] [FreeTDS] [SQL Server] Server unexpected EOF
ORA-02063: preceding 2 lines of EIMSPost the odbc.ini file that you use.
This may look like the wrong version of the TDS protocol is used with Dg4ODBC and FreeTDS.Published by: kgronau on 27 Sep, 2012 12:47
Add
TDS_Version = 8.0
QuotedId = YESto your odbc.ini
-
Portege M700 - 3 G-connection via Novatel & T-Mobile
Hello
My M700 is around the age of 12 months and now I tried to connect via a 3G connection to the internet. The build-in 3G connection manager Novatel (called MobiLink) offers 3 pre-installed configurations, none of them work for my T-Mobile SIM card.I can't find any clues (Toshiba or Novatel or T-Mobile) how to set up a working connection. I try to create a new profile, but have no idea on demand "APN:" or other necessary parameters.
Is there anyone with experience on these issues with a useful suggestion?
I know that my T-Mobile card user-number and the ANKLE associated with the SIM card.Thanks in advance,
PeterHi Riedel,
If I were you I talk with T-Mobile and ask what APN you should use. A digital CAMERA is basically a string that you enter to dictate the software to connect to (e.g. TMobile), T-Mobile will be able to tell you what APN you must try to connect to usually.
Good luck
Paul2008.
-
Equium L40 - unable to connect via wifi or cable plugged ubs
Hello
I have an Equium L40. I can not connect via wifi or cable plugged ubs.
It is a "Internet Explorer has stopped working. a problem caused the blocking of the program works correctly.He said in am connected to my hub and have a signal strong.
Can you help me
Thank you
Steve
Hello Steve
Have you tried using another browser?
Using Skype or some other messenger? None of them can connect properly?I put t know what is the real problem. Work not Internet Explore or WLAN connection in general?
-
Wireless router / Internet problems
I am running Windows Vista Home Edition with Security Essentials. I can connect to my wireless router, but cannot get internet connectivity via Wireless. If I connect the cable to the port on the router, I get internet connectivity. Is there a firewall setting that could cause this problem?Hello
Your router could be suspicious here, you have successfully updated its firmware as a possible solution? And I would like to
Update your WiFi drivers on computers. How you are positioned in the router? Are there
obstacles in the path?Actually try updating your driver and disabling the network logon.
Control Panel - network - write down of the brand and the model of the Wifi - double click top - tab of the driver - write
version - click the driver update (cannot do something that MS is far behind the pilots of certification). Then
Right click on the Wifi device and UNINSTALL - Reboot - it will refresh the driver stack.Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htmHow to install a device driver in Vista Device Manager
http://www.Vistax64.com/tutorials/193584-Device-Manager-install-driver.htmlDownload - SAVE - go where you put it - right click – RUN AS ADMIN.
You can download several at once however restart after the installation of each of them.
After watching the system manufacturer, you can check the manufacturer of the device an even newer version. (The
manufacturer of system become your backup policies).Repeat for network (NIC) card and is a good time to get the other updated drivers as Vista like
updated drivers.I would also turn off auto update for the drivers. If the updates Windows suggests a just HIDE as they
are almost always old, and you can search drivers manually as needed.How to disable automatic driver Installation in Windows Vista - drivers
http://www.AddictiveTips.com/Windows-Tips/how-to-disable-automatic-driver-installation-in-Windows-Vista/
http://TechNet.Microsoft.com/en-us/library/cc730606 (WS.10) .aspx------------------------------------------------------
Make sure you know the details of connection to your wireless router - SSID and password.
You lose connection when you do and have to redo your logon.
Control Panel - Network & Sharing Center - right, click Customize - page set of network locations.
lower left click on merge or delete network locations - REMOVE all instances of your network (and the
others you don't use anymore) - REBOOT. Start - Connect To log on to the network.-----------------------------------------------------
Check this box:
Strange problem with Internet under Vista
http://www.catonett.com/blog/archives/194Windows Vista cannot obtain an IP address from certain routers or some non-Microsoft DHCP servers
http://support.Microsoft.com/kb/928233/en-us----------------------------------------------------
And:
Network connection problems
http://windowshelp.Microsoft.com/Windows/en-us/help/33307acf-0698-41ba-B014-ea0a2eb8d0a81033.mspxI hope this helps.
Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle="" -="" mark="" twain="" said="" it="">->
-
Redirect 302 get only when connected via BES loop
Hello
I have a problem when I am connected via BES, I get a server redirection loop (it returns a 302 with the originial URL response in the "location" header field). When it is connected via the BIS-B, WiFi or carrier, the server returns redirects as expected and the app works. However I require a BES connection and him give a priority when they are available.
Note that I checked the connection returned by Networking.java string is correct (we add ";) (deviceside = false' when BES is to be using).
Here's the network code I use:
package [redacted] /* * Networking.java * * This code is based on the connection code developed by Mike Nelson of AccelGolf. * http://blog.accelgolf.com/2009/05/22/blackberry-cross-carrier-and-cross-network-http-connection * */ import net.rim.device.api.system.CoverageInfo; import net.rim.device.api.system.DeviceInfo; import net.rim.device.api.system.WLANInfo; public class Networking { Networking() { } // Whether or not to the simulator should use MDS to connect. // By default this should be false, however if you are testing // in an environment where MDS will be the expected connection method, // set this to true to have the simulator attempt to use MDS. This variable // has no effect on what happens on a real device. private static final boolean isMDS = false; // the timeout public static final int TIMEOUT = 30000; /** * Determines what connection type to use and returns the necessary string * to use it. * * @return A string with the connection info */ public static String getConnectionString() { String connectionString = null; // Simulator behavior is controlled by the USE_MDS_IN_SIMULATOR variable. if (DeviceInfo.isSimulator()) { if (isMDS) { connectionString = ";ConnectionTimeout=" + TIMEOUT + ";deviceside=false"; } else { connectionString = ";ConnectionTimeout=" + TIMEOUT + ";deviceside=true"; } } // Check for an MDS connection instead (BlackBerry Enterprise Server) else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) { System.out.println("MDS coverage found"); connectionString = ";ConnectionTimeout=" + TIMEOUT + ";deviceside=false"; } else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_BIS_B) == CoverageInfo.COVERAGE_BIS_B) { // otherwise, use the Uid to construct a valid carrier BIS-B request System.out.println("Using BIS"); connectionString = ";ConnectionTimeout=" + TIMEOUT + ";deviceside=false;ConnectionType=[redacted]"; } // Wifi is the preferred transmission method else if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) { System.out.println("Using WIFI"); connectionString = ";interface=wifi"; } // Is the carrier network the only way to connect? else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) { // Has carrier coverage, but not BIBS. So use the carrier's TCP network System.out.println("Device is connected Direct"); connectionString = ";ConnectionTimeout=" + TIMEOUT + ";deviceside=true"; } // If there is no connection available abort to avoid bugging the user unnecssarily. else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE) { System.out.println("There is no available connection."); } // In theory, all bases are covered so this shouldn't be reachable. else { System.out.println("no other options found, assuming device."); connectionString = ";ConnectionTimeout=" + TIMEOUT + ";deviceside=true"; } return connectionString; } }
Here is sendRequest managed the connection method and the redirection:
public HttpResponse sendRequest(HttpRequest request) { String url = request.getUrl(); if (url == null) { HttpResponse result = new HttpResponse(); result.responseCode = 404; result.responseMessage = "Not Found"; return result; } ConnectionWrapper cw = connectionWrapperForRequest(request); if (cw == null) { return null; } boolean compressionEnabled = !request.disableCompression() && COMPRESSION_ENABLED; HttpResponse result = new HttpResponse(); try { String finalURL = url.trim() + Networking.getConnectionString(); cw.connection = (HttpConnection) Connector.open(finalURL, Connector.READ_WRITE, false); System.out.println("Connection string: " + Networking.getConnectionString()); System.out.println("Full connec. URL: " + finalURL); if (cw.connection == null) { result.errorMessage = "Could not open a network connection."; result.completedWithError = true; return result; } cw.connection.setRequestMethod(request.getHttpMethod()); if (compressionEnabled) { cw.connection.setRequestProperty("Accept-Encoding", "gzip"); } cw.connection.setRequestProperty("User-Agent", "" + DeviceInfo.getManufacturerName() + "/" + DeviceInfo.getDeviceName() + "/" + Config.getVersionNumber()); if (request.username() != null) { cw.connection.setRequestProperty("Authorization", "Basic " + Utils.base64Encode(request.username() + ":" + request.password())); } // set this header so BES servers will not change the content of the headers cw.connection.setRequestProperty("x-rim-transcode-content", "none"); //add cookies if (HttpCookieJar.getInstance().cookieCount() > 0) { cw.connection.setRequestProperty("Cookie", HttpCookieJar.getInstance().getCookiesAsString()); } //pull request headers from HttpRequest Hashtable headers = request.getHeaders(); for (Enumeration e = headers.keys(); e.hasMoreElements();) { String key = (String) e.nextElement(); cw.connection.setRequestProperty(key, (String) headers.get(key)); } byte[] upstreamBytes = request.requestBytes(); if (upstreamBytes != null && upstreamBytes.length > 0) { Logger.getLogger().log(new String(upstreamBytes)); cw.connection.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_TYPE, HttpProtocolConstants.CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED); cw.connection.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_LENGTH, String.valueOf(upstreamBytes.length)); cw.outputStream = cw.connection.openOutputStream(); cw.outputStream.write(upstreamBytes); } Logger.getLogger().log("Get response"); result.responseCode = cw.connection.getResponseCode(); result.responseMessage = cw.connection.getResponseMessage(); Logger.getLogger().log("Status Code: " + result.responseCode); Logger.getLogger().log("Status Message: " + result.responseMessage); //suck out the cookies here int fieldNo = 0; String headerField; while ((headerField = cw.connection.getHeaderField(fieldNo)) != null) { if (cw.connection.getHeaderFieldKey(fieldNo).equals("Set-Cookie")) { HttpCookieJar.getInstance().setCookie(headerField); } fieldNo++; } System.out.println("get redirect"); //get redirect location String location; if ((location = cw.connection.getHeaderField("Location")) != null) { if (location == url.trim()) { Logger.getLogger().log("Redirect loop"); } Logger.getLogger().log("Redirect: " + location); result.redirectLocation = location.trim(); } else result.redirectLocation = null; byte[] buffer = new byte[HTTP_BUFFER_SIZE]; int count; System.out.println("compression"); cw.inputStream = cw.connection.openInputStream(); if (compressionEnabled) { String encoding = cw.connection.getEncoding(); if ("gzip".equalsIgnoreCase(encoding)) { cw.inputStream = new GZIPInputStream(cw.inputStream); } } cw.inputStream = new DataInputStream(cw.inputStream); System.out.println("output stream"); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { while ((count = cw.inputStream.read(buffer)) >= 0) { out.write(buffer, 0, count); } result.bytes = out.toByteArray(); } finally { out.close(); } cw.close(); Logger.getLogger().log("Response complete"); } catch (IOException e) { result.errorMessage = e.getMessage(); result.completedWithError = true; Logger.getLogger().log("ERROR!:" + e.getMessage()); } finally { removeConnectionWrapper(cw); } return result; }
Here's the whole HttpService.java for the context of the SendRequest method above:
//#preprocess //package //imports public class HttpService { private static HttpService _instance; private static final boolean COMPRESSION_ENABLED = false; private static final int HTTP_BUFFER_SIZE = 1024; public static synchronized HttpService instance() { if (_instance == null) { _instance = new HttpService(); } return _instance; } private WorkQueue _requestQueue = new WorkQueue(1024, 4); private Hashtable _connections = new Hashtable(10); private HttpService() { // singleton } private ConnectionWrapper connectionWrapperForRequest(HttpRequest request) { ConnectionWrapper cw = null; synchronized (request) { if (!request.cancelled()) { cw = new ConnectionWrapper(request); synchronized (_connections) { _connections.put(request, cw); } } } return cw; } private void removeConnectionWrapper(ConnectionWrapper cw) { synchronized (_connections) { _connections.remove(cw.request); } cw.close(); } public void cancelRequest(HttpRequest request) { ConnectionWrapper cw = null; synchronized (request) { synchronized (_connections) { cw = (ConnectionWrapper) _connections.remove(request); } request.setCancelled(); } if (cw != null) { cw.close(); } } public void executeRequest(final HttpRequest request) { _requestQueue.addWorkItem(new Runnable() { public void run() { HttpResponse response = sendRequest(request); if (!request.cancelled() && response != null) { request.completeRequest(response); } }; }); } public HttpResponse sendRequest(HttpRequest request) { String url = request.getUrl(); if (url == null) { HttpResponse result = new HttpResponse(); result.responseCode = 404; result.responseMessage = "Not Found"; return result; } ConnectionWrapper cw = connectionWrapperForRequest(request); if (cw == null) { return null; } boolean compressionEnabled = !request.disableCompression() && COMPRESSION_ENABLED; HttpResponse result = new HttpResponse(); try { String finalURL = url.trim() + Networking.getConnectionString(); cw.connection = (HttpConnection) Connector.open(finalURL, Connector.READ_WRITE, false); System.out.println("Connection string: " + Networking.getConnectionString()); System.out.println("Full connec. URL: " + finalURL); if (cw.connection == null) { result.errorMessage = "Could not open a network connection."; result.completedWithError = true; return result; } cw.connection.setRequestMethod(request.getHttpMethod()); if (compressionEnabled) { cw.connection.setRequestProperty("Accept-Encoding", "gzip"); } cw.connection.setRequestProperty("User-Agent", "" + DeviceInfo.getManufacturerName() + "/" + DeviceInfo.getDeviceName() + "/" + Config.getVersionNumber()); if (request.username() != null) { cw.connection.setRequestProperty("Authorization", "Basic " + Utils.base64Encode(request.username() + ":" + request.password())); } // set this header so BES servers will not change the content of the headers cw.connection.setRequestProperty("x-rim-transcode-content", "none"); //add cookies if (HttpCookieJar.getInstance().cookieCount() > 0) { cw.connection.setRequestProperty("Cookie", HttpCookieJar.getInstance().getCookiesAsString()); } //pull request headers from HttpRequest Hashtable headers = request.getHeaders(); for (Enumeration e = headers.keys(); e.hasMoreElements();) { String key = (String) e.nextElement(); cw.connection.setRequestProperty(key, (String) headers.get(key)); } byte[] upstreamBytes = request.requestBytes(); if (upstreamBytes != null && upstreamBytes.length > 0) { Logger.getLogger().log(new String(upstreamBytes)); cw.connection.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_TYPE, HttpProtocolConstants.CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED); cw.connection.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_LENGTH, String.valueOf(upstreamBytes.length)); cw.outputStream = cw.connection.openOutputStream(); cw.outputStream.write(upstreamBytes); } Logger.getLogger().log("Get response"); result.responseCode = cw.connection.getResponseCode(); result.responseMessage = cw.connection.getResponseMessage(); Logger.getLogger().log("Status Code: " + result.responseCode); Logger.getLogger().log("Status Message: " + result.responseMessage); //suck out the cookies here int fieldNo = 0; String headerField; while ((headerField = cw.connection.getHeaderField(fieldNo)) != null) { if (cw.connection.getHeaderFieldKey(fieldNo).equals("Set-Cookie")) { HttpCookieJar.getInstance().setCookie(headerField); } fieldNo++; } System.out.println("get redirect"); //get redirect location String location; if ((location = cw.connection.getHeaderField("Location")) != null) { if (location == url.trim()) { Logger.getLogger().log("Redirect loop"); } Logger.getLogger().log("Redirect: " + location); result.redirectLocation = location.trim(); } byte[] buffer = new byte[HTTP_BUFFER_SIZE]; int count; System.out.println("compression"); cw.inputStream = cw.connection.openInputStream(); if (compressionEnabled) { String encoding = cw.connection.getEncoding(); if ("gzip".equalsIgnoreCase(encoding)) { cw.inputStream = new GZIPInputStream(cw.inputStream); } } cw.inputStream = new DataInputStream(cw.inputStream); System.out.println("output stream"); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { while ((count = cw.inputStream.read(buffer)) >= 0) { out.write(buffer, 0, count); } result.bytes = out.toByteArray(); } finally { out.close(); } cw.close(); Logger.getLogger().log("Response complete"); } catch (IOException e) { result.errorMessage = e.getMessage(); result.completedWithError = true; Logger.getLogger().log("ERROR!:" + e.getMessage()); } finally { removeConnectionWrapper(cw); } return result; } private static class ConnectionWrapper { final HttpRequest request; InputStream inputStream = null; OutputStream outputStream = null; HttpConnection connection = null; public ConnectionWrapper(HttpRequest request) { this.request = request; } public void close() { try { if (outputStream != null) outputStream.close(); } catch (Exception e) { } try { if (inputStream != null) inputStream.close(); } catch (Exception e) { } try { if (connection != null) connection.close(); } catch (Exception e) { } } } }
Sorry for the amount of code.
I had our BES admin visit problematic page via a browser on the Server BES itself.
Running, the Web server was an update of AJAX-style page that informs the user that they had no access to that particular content. Programmatically, see us all is "the page has been moved here" - but in a browser, it's a different story.
Thanks again Peter for your insight!
Maybe you are looking for
-
How to change the priority of boot CD-ROM on the ProBook s 4530?
-
Disappeared from my bar start, how can I get him back?
I tried to upload a video to a DvD and the program was not respond so I closed it. When it is closed, my start bar has disappeared and I can't get it back. I tried to restart my computer and pressing the key windows on my keyboard, but nothing happen
-
Journal of the events of blackBerry Smartphones
ALT-LGLG Displays the event log that I discovered. I did a search, but I can't find anything that explains what it is or how it is used. Must/should this not be sometimes erased or deleted to free up memory. Can someone point/direct me to the right
-
Is there a way I can create a voice active my windows user account password 7?
original title: user password? Is there a way I can create a voice active my windows user account password 7?
-
HP touchsmart 310-1020 webcam does not work
the integrated webcam does not work. In touchsmart, when you click on the webcam, she began, but starts immediately. How to update or download a new driver? Device driver, it says it's updated? OT: I have a HP touchsmart 310-1020...