Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4564626
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:31:40+00:00 2026-05-21T18:31:40+00:00

I want to build a simple code generator in java that can take database

  • 0

I want to build a simple code generator in java that can take database connection string and then create the model layer for each table in database , I don’t know how can I do that , so if any one has any tutorial or links that may help me complete this task i will be thankful

Thanks in Advance


I have found a good example on code project that can take the database and make a good code generation for the tables in database , but unfortunately it is written in C# and also generate C# code

I don’t know if it right to generate C# code and then convert them to java using any conversion software , or the right thing is to try to modify it to generate java classes instead of C# classes

by the way the link for the example is http://www.codeproject.com/KB/codegen/TierGenerator.aspx

I need your advice as soon as you can

Thanks in Advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T18:31:41+00:00Added an answer on May 21, 2026 at 6:31 pm

    For quick and simple code generator: Just write the java source code into a StringBuilder and dump it’s content to a .java file. I never used third party libs for simple autogenerators:

    StringBuilder sourceBuilder = new StringBuilder();
    sourceBuilder.append("package com.example.beans;\n\n");
    sourceBuilder.append("import java.util.*;\n\n");
    sourceBuilder.append("public class MyBean {");
    
    for (DBField dbField:getFieldsFromDatabaseModel) {  // this DBField class is pure fiction!
      // bean attribute
      sourceBuilder.append("\tprivate ")
                   .append(dbField.getType)
                   .append(toFieldName(dbField.getName()))
                   .append(" = null;\n");
    
      // setter method
      sourceBuilder.append("\tpublic void ")
                   .append(toSetterName(dbField.getName()))
                   .append("(");
                   .append(dbField.getType)
                   .append(toFieldName(dbField.getName()))
                   .append(")\n")
                   .append("\t\tthis.")
                   .append(dbField.getType)
                   .append(" = ")
                   .append(dbField.getType)
                   .append(";\n\t}");
    
       // getter method ...
    sourceBuilder.append("\t}\n}\n");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to build a bot that asks someone a few simple questions and
I want to build an SQL string to do database manipulation (updates, deletes, inserts,
I want to build a site where the user can enter text and format
I want to build something like a network scanner, so that I see in
I've got a simple (inline) ASPX page that is ouputting XML. I want to
I want to use a temp directory that will be unique to this build.
I want to build a lightweight linux configuration to use for development. The first
I want to build my own custom log4j (network) adapter to solve my problem
I want to build an executable to distribute to people without python installed on
I want to build two-dimentional array of strings where length of one dimention is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.