473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

MySQL Getting Started

539 512MB
Good day,

Im currently developing a Java API to be used for our project( Simple website using JSP ).

Now, i really don't have any idea how to create a MySQL query like this,

SELECT COLUMN 3 FROM TABLE WHERE COLUMN 1 = "SOMETHING"

This is what i've planned for a specific class named SQLDriver

I know how to reproduced that one,
select columnname1 from sukatoa where columnname2 = "blah2x";

But i need an integer parameter coming from the other class that will be used for querying, We have another java class that only returns an integer that represents the column of a table, and it is dynamically changing(The very worst case)....

So, is it possible? Can you show me some recommended urls for this kind of tutorial?

Im looking forward to your replies,
sukatoa
Jul 19 '08 #1
7 1427
amitpatel66
2,367 Expert 2GB
You want to dynamically change the columns that you select in your query or in the where condition?
Jul 21 '08 #2
r035198x
13,262 8TB
Normally you specify the order you want to retrive the values with in your select clause. If you want users to select which column they want (can't think of why you'd want to do that) then making them supply a number is certainly weird. Perhaps make then supply the column name?
You could of course get all the values and then into a resultset and then use rs.getObject(variableIndex).
Jul 22 '08 #3
sukatoa
539 512MB
You could of course get all the values and then into a resultset and then use rs.getObject(variableIndex).
Im gonna try that one,

Actually, im trying to extend the class DataSetHandler @ reply #6....

The code that you will see there is actually the initial structure, but the final is far the same from that one, but the concept is similar.....

Now, instead of having the column names, i only need the nth column (node) to be used for querying.....
Jul 25 '08 #4
chaarmann
785 Expert 512MB
Why don't you just get the metadata from the table?
Then for example if you have the integer=3, then just retrieve the name of the third column from there and use it for your SQL-command.

Expand|Select|Wrap|Line Numbers
  1. Connection con = ...;
  2. DatabaseMetaData dbmd = con.getMetaData();
  3. ResultSet rs = dbmd.getColumns( null, null, tableName, null );
  4. while ( rs.next() ) // for each table column
  5. {
  6. // get data
  7. String columnName = rs.getString("COLUMN_NAME");
  8. ...
Jul 25 '08 #5
sukatoa
539 512MB
Thanks for the replies.........

Now, i need help searching for the error given the below constants....

"(usr varchar(255)," +
"pwd varchar(255)," +
"email varchar(255)," +
"ccnumber varchar(255)," +
"foreign varchar(255)," +
"passport varchar(255)," +
"placeissue varchar(255)," +
"surname varchar(255)," +
"firstname varchar(255)," +
"middlename varchar(255)," +
"homeadd varchar(255)," +
"cmpnyadd varchar(255)," +
"birthdate varchar(255)," +
"gender varchar(255)," +
"country varchar(255)," +
"landline varchar(255)," +
"mobile varchar(255)," +
"faxnumber varchar(255)," +
"altermail varchar(255)," +
"signedin INTEGER," +
"blacklisted varchar(255)," +
"successRSVN INTEGER);";

I am trying to create database and a table using Java..... through querying....

ERROR:

MySQLSyntaxErrorException:
See the manual for the following correct syntax to use near

Expand|Select|Wrap|Line Numbers
  1. 'varchar(255),passport varchar(255),placeissue varchar(255),surname varchar(255),
Can you point me where in my code are the incorrect syntax?

I have concat the values after this query:
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE IF NOT EXISTS member
Aug 25 '08 #6
sukatoa
539 512MB
I realize that creating a foreign variable is the issue here.....
im using MySQL 5.0

Is foreign a MySQL keyword?

could you point me experts why is that so?
Aug 25 '08 #7
r035198x
13,262 8TB
I realize that creating a foreign variable is the issue here.....
im using MySQL 5.0

Is foreign a MySQL keyword?

could you point me experts why is that so?
Here is the full list.
Aug 25 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: I.P. | last post by:
Hi, it's my story. I have two 4.0.14 mysql server on one machine with win XP Professional polish version. First acts as master: on port 3300 Second acts as slave: on port 3301 below my...
0
by: I.P. | last post by:
No one has replied to my post. ----- Original Message ----- From: "I.P." <jancio_wodnik@wp.pl> To: <mysql@lists.mysql.com> Sent: Monday, August 18, 2003 1:01 PM Subject: mysql 4.0.14 +...
6
by: Jim Flack | last post by:
I have a new website hosted by www.easily.co.uk which contains a mysql database (I have the initial access codes etc ). My problem is I have never used PHP or dealt with mysql before. I have tried...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
2
by: jmlynn | last post by:
Help! I installed MySQL 4.0.20C and it works if I started it with mysqld --console However, if I do the following: mysqld --install net start MySQL
0
by: tamdino | last post by:
Please accept my apologies if I am posting this in the wrong place. I am trying to get started using MySQL-Front and I am totally lost. Does anyone know where there is a tutorial for getting...
1
by: jlee | last post by:
I'm pretty much a newbie on mysql, and I need some help. I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4 (i386) on a server hosting an active website. The site's developer...
3
by: auron | last post by:
Hi there, I have a really stupid and banal problem with showing the results of a MySQL query in PHP, preciselly with MySQL count() function that gives to a variable in PHP the result. NOTE:...
4
by: Richard | last post by:
Hi All, I've been trying to build a Ruby-on-Rails plus MySQL application. I'm running Ruby 1.8.2, Rails 1.1.4 and MySQL 5.0.15-nt over WinXP-Pro/SP2. I run under an Administrative account. ...
2
by: Troy Piggins | last post by:
We have some php pages on our intranet at work that have been working fine for years. As a result, they rarely get edited. The page I'm having trouble with is a timesheet entry page which uses...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.