Hello,
Under mysql, we have "desc tablename" to get the detail information
about a table. My question is about to get column name, and column type
for a specific table under PostgreSQL through JDBC.
Assume we have a table named "test". Under PSQL, we can input "\d test"
to see the details about table "test" successufully. However, my main
purpose is trying to get column name, column name of a table through JDBC.
The following is the java code, by which I always get " ERROR: syntax
error at or near "\" ".
Some clues?
Emi
=============== =============== =============== =============== =============== =========
Connection connection = DriverManager.g etConnection(ur l,
"abc", "abc"); //username and pwd is "abc"
Statement stmt = connection.crea teStatement();
String query = "\\d test";
System.out.prin tln("query: "+query);
ResultSet rs = stmt.executeQue ry(query);
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster 4 6461
On 02/09/2004 15:52 Ying Lu wrote: Hello,
Under mysql, we have "desc tablename" to get the detail information about a table. My question is about to get column name, and column type for a specific table under PostgreSQL through JDBC.
Assume we have a table named "test". Under PSQL, we can input "\d test" to see the details about table "test" successufully. However, my main purpose is trying to get column name, column name of a table through JDBC.
The following is the java code, by which I always get " ERROR: syntax error at or near "\" ".
Some clues?
The \d command is a psql client feature. I has nothing to do with JDBC and
is not built into the server back-end (a few moments reading the source
code for psql would have shown you this). To obtain metadata through JDBC,
use the standard provided classes. If you don't know how to that then you
really need to learn JDBC. There's a good introductory tutorial on
java.sun.com
--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for
Business |
| Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+---------------------------------------------+
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org
have a look at java.sql.Connec tion.getDatabas eMetadata()
(and the object, java.sql.Databa seMetaData it returns) -----Messaggio originale----- Da: pg************* ****@postgresql .org [mailto:pg****** ***********@pos tgresql.org]Per conto di Ying Lu Inviato: giovedì 2 settembre 2004 16.53 A: pg***********@p ostgresql.org Oggetto: [GENERAL] "\d tablename" to get column name, and column type by using JDBC
Hello,
Under mysql, we have "desc tablename" to get the detail information about a table. My question is about to get column name, and column type for a specific table under PostgreSQL through JDBC.
Assume we have a table named "test". Under PSQL, we can input "\d test" to see the details about table "test" successufully. However, my main purpose is trying to get column name, column name of a table through JDBC.
The following is the java code, by which I always get " ERROR: syntax error at or near "\" ".
Some clues? Emi
=============== =============== =============== =============== ====== =============== === Connection connection = DriverManager.g etConnection(ur l, "abc", "abc"); //username and pwd is "abc" Statement stmt = connection.crea teStatement(); String query = "\\d test"; System.out.prin tln("query: "+query); ResultSet rs = stmt.executeQue ry(query);
---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
Ying Lu <yi*****@cs.con cordia.ca> writes: Hello,
Under mysql, we have "desc tablename" to get the detail information about a table. My question is about to get column name, and column type for a specific table under PostgreSQL through JDBC.
Assume we have a table named "test". Under PSQL, we can input "\d test" to see the details about table "test" successufully. However, my main purpose is trying to get column name, column name of a table through JDBC.
The backslash commands are specific to 'psql'. From Java you'll need
to query the INFORMATION_SCH EMA or the system catalogs.
-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)
Thanks a lot. Now I got it.
Doug McNaught wrote: Ying Lu <yi*****@cs.con cordia.ca> writes: Hello,
Under mysql, we have "desc tablename" to get the detail information about a table. My question is about to get column name, and column type for a specific table under PostgreSQL through JDBC.
Assume we have a table named "test". Under PSQL, we can input "\d test" to see the details about table "test" successufully. However, my main purpose is trying to get column name, column name of a table through JDBC.
The backslash commands are specific to 'psql'. From Java you'll need to query the INFORMATION_SCH EMA or the system catalogs.
-Doug
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Liam3 |
last post by:
I'm having a problem with a table that accidently had a column added
whose type is the same as the table. This is seriously creating a
problem as I cannot delete the table and I really don't have the
ability to destroy the database (with all the other tables) just to
get rid of this. Does anyone know of a way to get the database to
allow a drop of a table that has this sort of situation.
Here's a sample of what I get...
Any thoughts...
|
by: azamka |
last post by:
Hi everyone,
I am trying to create tables with type innodb. I created a database and all
the tables of type ISAM. Now I am at the point of making relations and
establish refrential integrity. For that ofcourse I have to change the tables
in the Innodb type. I did that with the commad "alter table tablename type =
innodb". Command runs fine but the table type doesnt change. I tried to create
a new table of type innodb but its not working...
|
by: hch |
last post by:
dataAdapter.Update(data, "TableName") won’t work!
I was about to deploy my first website on the Internet only to discover that
the dataAdapter.Update() throws the Server Error in the third underline. It
was working fine before.
ConnectionString in Web.config:
-----------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
|
by: L Mehl |
last post by:
Hello --
I am not yet an advanced SQL code writer.
Can someone help me add the extended property 'Description' to a list of
columns resulting from this code?
SELECT
SUBSTRING(table_name,1,20) AS "Table",
SUBSTRING(column_name,1,30) AS "Column",
|
by: mjf |
last post by:
Hello,
Is there a way to export the data from some tables, along with their
corresponding column names? I know I can use "export" command to export
the data from a table to a DEL file (the users need to be able to read
the file directly, which leaves the choice of a DEL file), but only the
data will be in the file. The users would like to see the column names
side by side with the data as well. I wonder if there is an easy way to
do so...
| |
by: Giacomo |
last post by:
Hi,
I've the following problem. I must delete a column DEFAULT from a table,
but I must do it with a script, independently from the server where it'll
be executed.
Locally I've tried with:
ALTER TABLE .
DROP CONSTRAINT
GO
|
by: Spanco |
last post by:
Dear All ,
Can anybody Tell me the Code for renaming the Column in the dataview.
I used the following but it is not working
Tablename.Column(Index).ColumnName.Replace(Old ColumnName,New Column name)
Requirement: Except first Column All the column should be Blank or space
|
by: Dan |
last post by:
Hello, all!
New here, so please forgive if this has been answered before. I use
MySQL most often, and can use the commands:
show tables in ;
show columns in ;
which lists all the tables in the specified database, and columns/
fields in the specified table. Is there an SQL equivalent for use in
|
by: kalyson |
last post by:
Hello,
I realize that using the TYPE declaration for variables makes their definitions more dynamic, like this:
myField tablename.name%TYPE;
myRow tablename%ROWTYPE;
But I also want to be able to change the name of the table in the code.
So I want to have "tablename" above refer to a VARIABLE that contains the name of a table, so I don't have to go changing the tablename throughout the code if the table name...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |